Update app.py
Browse files
app.py
CHANGED
|
@@ -44,17 +44,17 @@ def load_model(model_tag, vocoder_tag):
|
|
| 44 |
|
| 45 |
gos_text2speech = load_model('https://huggingface.co/wietsedv/tacotron2-gronings/resolve/main/tts_ljspeech_finetune_tacotron2.v5_train.loss.ave.zip', 'wietsedv/parallelwavegan-gronings')
|
| 46 |
nld_text2speech = load_model('https://huggingface.co/wietsedv/tacotron2-dutch/resolve/main/tts_ljspeech_finetune_tacotron2.v5_train.loss.ave.zip', 'wietsedv/parallelwavegan-dutch')
|
| 47 |
-
eng_text2speech = Text2Speech.from_pretrained(
|
| 48 |
-
model_tag="kan-bayashi/ljspeech_tacotron2",
|
| 49 |
-
vocoder_tag="parallel_wavegan/ljspeech_parallel_wavegan.v3",
|
| 50 |
-
device="cpu",
|
| 51 |
-
threshold=0.5,
|
| 52 |
-
minlenratio=0.0,
|
| 53 |
-
maxlenratio=10.0,
|
| 54 |
-
use_att_constraint=True,
|
| 55 |
-
backward_window=1,
|
| 56 |
-
forward_window=4,
|
| 57 |
-
)
|
| 58 |
|
| 59 |
def inference(text,lang):
|
| 60 |
with torch.no_grad():
|
|
@@ -64,9 +64,9 @@ def inference(text,lang):
|
|
| 64 |
if lang == "dutch":
|
| 65 |
wav = nld_text2speech(text)["wav"]
|
| 66 |
scipy.io.wavfile.write("out.wav", nld_text2speech.fs , wav.view(-1).cpu().numpy())
|
| 67 |
-
if lang == "english":
|
| 68 |
-
|
| 69 |
-
|
| 70 |
|
| 71 |
return "out.wav", "out.wav"
|
| 72 |
|
|
@@ -77,8 +77,8 @@ examples = [
|
|
| 77 |
|
| 78 |
gr.Interface(
|
| 79 |
inference,
|
| 80 |
-
[gr.inputs.Textbox(label="input text", lines=3), gr.inputs.Radio(choices=["gronings", "dutch"
|
| 81 |
[gr.outputs.Audio(type="file", label="Output"), gr.outputs.File()],
|
| 82 |
title=title,
|
| 83 |
examples=examples
|
| 84 |
-
).launch(enable_queue=True
|
|
|
|
| 44 |
|
| 45 |
gos_text2speech = load_model('https://huggingface.co/wietsedv/tacotron2-gronings/resolve/main/tts_ljspeech_finetune_tacotron2.v5_train.loss.ave.zip', 'wietsedv/parallelwavegan-gronings')
|
| 46 |
nld_text2speech = load_model('https://huggingface.co/wietsedv/tacotron2-dutch/resolve/main/tts_ljspeech_finetune_tacotron2.v5_train.loss.ave.zip', 'wietsedv/parallelwavegan-dutch')
|
| 47 |
+
#eng_text2speech = Text2Speech.from_pretrained(
|
| 48 |
+
# model_tag="kan-bayashi/ljspeech_tacotron2",
|
| 49 |
+
# vocoder_tag="parallel_wavegan/ljspeech_parallel_wavegan.v3",
|
| 50 |
+
# device="cpu",
|
| 51 |
+
# threshold=0.5,
|
| 52 |
+
# minlenratio=0.0,
|
| 53 |
+
# maxlenratio=10.0,
|
| 54 |
+
# use_att_constraint=True,
|
| 55 |
+
# backward_window=1,
|
| 56 |
+
# forward_window=4,
|
| 57 |
+
#)
|
| 58 |
|
| 59 |
def inference(text,lang):
|
| 60 |
with torch.no_grad():
|
|
|
|
| 64 |
if lang == "dutch":
|
| 65 |
wav = nld_text2speech(text)["wav"]
|
| 66 |
scipy.io.wavfile.write("out.wav", nld_text2speech.fs , wav.view(-1).cpu().numpy())
|
| 67 |
+
#if lang == "english":
|
| 68 |
+
# wav = eng_text2speech(text)["wav"]
|
| 69 |
+
# scipy.io.wavfile.write("out.wav", eng_text2speech.fs , wav.view(-1).cpu().numpy())
|
| 70 |
|
| 71 |
return "out.wav", "out.wav"
|
| 72 |
|
|
|
|
| 77 |
|
| 78 |
gr.Interface(
|
| 79 |
inference,
|
| 80 |
+
[gr.inputs.Textbox(label="input text", lines=3), gr.inputs.Radio(choices=["gronings", "dutch"], type="value", default="gronings", label="language")],
|
| 81 |
[gr.outputs.Audio(type="file", label="Output"), gr.outputs.File()],
|
| 82 |
title=title,
|
| 83 |
examples=examples
|
| 84 |
+
).launch(enable_queue=True)
|