Martijn Bartelds
commited on
Commit
·
a4a22fd
1
Parent(s):
7c1157d
Update app
Browse files
app.py
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import time
|
3 |
-
import urllib.request
|
4 |
-
from pathlib import Path
|
5 |
import os
|
|
|
6 |
import torch
|
7 |
-
import
|
|
|
8 |
import numpy as np
|
|
|
9 |
from espnet2.bin.tts_inference import Text2Speech
|
10 |
from espnet2.utils.types import str_or_none
|
11 |
-
|
12 |
|
13 |
gos_text2speech = Text2Speech.from_pretrained(
|
14 |
model_tag="bartelds/gos_tts",
|
@@ -22,13 +21,13 @@ def inference(text,lang):
|
|
22 |
with torch.no_grad():
|
23 |
if lang == "Hoogelaandsters":
|
24 |
wav = gos_text2speech(text.lower(), sids=np.array([1]))["wav"]
|
25 |
-
|
26 |
if lang == "Oldambsters":
|
27 |
wav = gos_text2speech(text.lower(), sids=np.array([2]))["wav"]
|
28 |
-
|
29 |
if lang == "Westerkertaaiers":
|
30 |
wav = gos_text2speech(text.lower(), sids=np.array([3]))["wav"]
|
31 |
-
|
32 |
|
33 |
return "out.wav", "out.wav"
|
34 |
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
import time
|
3 |
import torch
|
4 |
+
import urllib.request
|
5 |
+
import gradio as gr
|
6 |
import numpy as np
|
7 |
+
import soundfile as sf
|
8 |
from espnet2.bin.tts_inference import Text2Speech
|
9 |
from espnet2.utils.types import str_or_none
|
10 |
+
from pathlib import Path
|
11 |
|
12 |
gos_text2speech = Text2Speech.from_pretrained(
|
13 |
model_tag="bartelds/gos_tts",
|
|
|
21 |
with torch.no_grad():
|
22 |
if lang == "Hoogelaandsters":
|
23 |
wav = gos_text2speech(text.lower(), sids=np.array([1]))["wav"]
|
24 |
+
sf.write("out.wav", wav.view(-1).cpu().numpy(), gos_text2speech.fs)
|
25 |
if lang == "Oldambsters":
|
26 |
wav = gos_text2speech(text.lower(), sids=np.array([2]))["wav"]
|
27 |
+
sf.write("out.wav", wav.view(-1).cpu().numpy(), gos_text2speech.fs)
|
28 |
if lang == "Westerkertaaiers":
|
29 |
wav = gos_text2speech(text.lower(), sids=np.array([3]))["wav"]
|
30 |
+
sf.write("out.wav", wav.view(-1).cpu().numpy(), gos_text2speech.fs)
|
31 |
|
32 |
return "out.wav", "out.wav"
|
33 |
|