mirror of
https://github.com/babysor/MockingBird.git
synced 2024-03-22 13:11:31 +08:00
Allow to select vocoder in web
This commit is contained in:
parent
2bd323b7df
commit
6c8f3f4515
|
@ -31,7 +31,7 @@ def webApp():
|
||||||
synthesizers = list(Path(syn_models_dirt).glob("**/*.pt"))
|
synthesizers = list(Path(syn_models_dirt).glob("**/*.pt"))
|
||||||
synthesizers_cache = {}
|
synthesizers_cache = {}
|
||||||
encoder.load_model(Path("encoder/saved_models/pretrained.pt"))
|
encoder.load_model(Path("encoder/saved_models/pretrained.pt"))
|
||||||
# rnn_vocoder.load_model(Path("vocoder/saved_models/pretrained/pretrained.pt"))
|
rnn_vocoder.load_model(Path("vocoder/saved_models/pretrained/pretrained.pt"))
|
||||||
gan_vocoder.load_model(Path("vocoder/saved_models/pretrained/g_hifigan.pt"))
|
gan_vocoder.load_model(Path("vocoder/saved_models/pretrained/g_hifigan.pt"))
|
||||||
|
|
||||||
def pcm2float(sig, dtype='float32'):
|
def pcm2float(sig, dtype='float32'):
|
||||||
|
@ -107,12 +107,14 @@ def webApp():
|
||||||
embeds = [embed] * len(texts)
|
embeds = [embed] * len(texts)
|
||||||
specs = current_synt.synthesize_spectrograms(texts, embeds)
|
specs = current_synt.synthesize_spectrograms(texts, embeds)
|
||||||
spec = np.concatenate(specs, axis=1)
|
spec = np.concatenate(specs, axis=1)
|
||||||
# wav = rnn_vocoder.infer_waveform(spec)
|
if "vocoder" in request.form and request.form["vocoder"] == "WaveRNN":
|
||||||
wav = gan_vocoder.infer_waveform(spec)
|
wav = rnn_vocoder.infer_waveform(spec)
|
||||||
|
else:
|
||||||
|
wav = gan_vocoder.infer_waveform(spec)
|
||||||
|
|
||||||
# Return cooked wav
|
# Return cooked wav
|
||||||
out = io.BytesIO()
|
out = io.BytesIO()
|
||||||
write(out, Synthesizer.sample_rate, wav)
|
write(out, Synthesizer.sample_rate, wav.astype(np.float32))
|
||||||
return Response(out, mimetype="audio/wav")
|
return Response(out, mimetype="audio/wav")
|
||||||
|
|
||||||
@app.route('/', methods=['GET'])
|
@app.route('/', methods=['GET'])
|
||||||
|
|
|
@ -61,7 +61,16 @@
|
||||||
<div class="pd btns" style="margin-left: 5%;margin-top: 20px;width: 90%; ">
|
<div class="pd btns" style="margin-left: 5%;margin-top: 20px;width: 90%; ">
|
||||||
<div style="font-size: larger;font-weight: bolder;">3. 选择Synthesizer模型</div>
|
<div style="font-size: larger;font-weight: bolder;">3. 选择Synthesizer模型</div>
|
||||||
<span class="box">
|
<span class="box">
|
||||||
<select id="select">
|
<select id="selectSynt">
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="pd btns" style="margin-left: 5%;margin-top: 20px;width: 90%; ">
|
||||||
|
<div style="font-size: larger;font-weight: bolder;">4. 选择Vocoder模型</div>
|
||||||
|
<span class="box">
|
||||||
|
<select id="selectVocoder">
|
||||||
|
<option>WaveRNN</option>
|
||||||
|
<option>HifiGAN</option>
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -116,7 +125,7 @@
|
||||||
var option = document.createElement('option');
|
var option = document.createElement('option');
|
||||||
option.text = synt.name
|
option.text = synt.name
|
||||||
option.value = synt.path
|
option.value = synt.path
|
||||||
$("#select").append(option);
|
$("#selectSynt").append(option);
|
||||||
}
|
}
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
console.log('Error: ' + err.message);
|
console.log('Error: ' + err.message);
|
||||||
|
@ -266,11 +275,16 @@
|
||||||
var postData = new FormData();
|
var postData = new FormData();
|
||||||
postData.append("text", input_text)
|
postData.append("text", input_text)
|
||||||
postData.append("file", blob)
|
postData.append("file", blob)
|
||||||
var sel = document.getElementById("select");
|
var syntSelect = document.getElementById("selectSynt");
|
||||||
var path = sel.options[sel.selectedIndex].value;
|
var path = syntSelect.options[syntSelect.selectedIndex].value;
|
||||||
if (!!path) {
|
if (!!path) {
|
||||||
postData.append("synt_path", path);
|
postData.append("synt_path", path);
|
||||||
}
|
}
|
||||||
|
var vocoderSelect = document.getElementById("selectVocoder");
|
||||||
|
var vocoder = vocoderSelect.options[vocoderSelect.selectedIndex].value;
|
||||||
|
if (!!vocoder) {
|
||||||
|
postData.append("vocoder", vocoder);
|
||||||
|
}
|
||||||
|
|
||||||
fetch(api, {
|
fetch(api, {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user