diff --git a/web/__init__.py b/web/__init__.py index 330c91d..e0bf9ca 100644 --- a/web/__init__.py +++ b/web/__init__.py @@ -31,7 +31,7 @@ def webApp(): synthesizers = list(Path(syn_models_dirt).glob("**/*.pt")) synthesizers_cache = {} 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")) def pcm2float(sig, dtype='float32'): @@ -107,12 +107,14 @@ def webApp(): embeds = [embed] * len(texts) specs = current_synt.synthesize_spectrograms(texts, embeds) spec = np.concatenate(specs, axis=1) - # wav = rnn_vocoder.infer_waveform(spec) - wav = gan_vocoder.infer_waveform(spec) + if "vocoder" in request.form and request.form["vocoder"] == "WaveRNN": + wav = rnn_vocoder.infer_waveform(spec) + else: + wav = gan_vocoder.infer_waveform(spec) # Return cooked wav out = io.BytesIO() - write(out, Synthesizer.sample_rate, wav) + write(out, Synthesizer.sample_rate, wav.astype(np.float32)) return Response(out, mimetype="audio/wav") @app.route('/', methods=['GET']) diff --git a/web/templates/index.html b/web/templates/index.html index d8cfac4..2ef072d 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -61,7 +61,16 @@
3. 选择Synthesizer模型
- + + +
+
+
4. 选择Vocoder模型
+ +
@@ -116,7 +125,7 @@ var option = document.createElement('option'); option.text = synt.name option.value = synt.path - $("#select").append(option); + $("#selectSynt").append(option); } }).catch(function (err) { console.log('Error: ' + err.message); @@ -266,11 +275,16 @@ var postData = new FormData(); postData.append("text", input_text) postData.append("file", blob) - var sel = document.getElementById("select"); - var path = sel.options[sel.selectedIndex].value; + var syntSelect = document.getElementById("selectSynt"); + var path = syntSelect.options[syntSelect.selectedIndex].value; if (!!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, { method: 'post',