Martijn Bartelds
commited on
Commit
·
46ebc44
1
Parent(s):
7ca2569
Update app
Browse files
app.py
CHANGED
@@ -17,19 +17,26 @@ gos_text2speech = Text2Speech.from_pretrained(
|
|
17 |
noise_scale_dur=1.0
|
18 |
)
|
19 |
|
20 |
-
def inference(text,lang):
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
title = "Gronings text-to-speech"
|
35 |
examples = [
|
@@ -39,7 +46,7 @@ examples = [
|
|
39 |
gr.Interface(
|
40 |
inference,
|
41 |
[gr.inputs.Textbox(label="Input text", lines=3), gr.inputs.Radio(choices=["Hoogelaandsters", "Oldambsters", "Westerkertaaiers"], type="value", default="Hoogelaandsters", label="Variant")],
|
42 |
-
[gr.outputs.Audio(type="
|
43 |
title=title,
|
44 |
examples=examples
|
45 |
).launch(enable_queue=True)
|
|
|
17 |
noise_scale_dur=1.0
|
18 |
)
|
19 |
|
20 |
+
def inference(text, lang):
|
21 |
+
with torch.no_grad():
|
22 |
+
lines = text.splitlines()
|
23 |
+
outputs = []
|
24 |
+
|
25 |
+
for line in lines:
|
26 |
+
line = line.lower()
|
27 |
+
if lang == "Hoogelaandsters":
|
28 |
+
wav = gos_text2speech(line, sids=np.array([1]))["wav"]
|
29 |
+
elif lang == "Oldambsters":
|
30 |
+
wav = gos_text2speech(line, sids=np.array([2]))["wav"]
|
31 |
+
elif lang == "Westerkertaaiers":
|
32 |
+
wav = gos_text2speech(line, sids=np.array([3]))["wav"]
|
33 |
+
|
34 |
+
outputs.append(wav)
|
35 |
+
|
36 |
+
concatenated_wav = np.concatenate([o.view(-1).cpu().numpy() for o in outputs])
|
37 |
+
sf.write("out.wav", concatenated_wav, gos_text2speech.fs)
|
38 |
+
|
39 |
+
return "out.wav", "out.wav"
|
40 |
|
41 |
title = "Gronings text-to-speech"
|
42 |
examples = [
|
|
|
46 |
gr.Interface(
|
47 |
inference,
|
48 |
[gr.inputs.Textbox(label="Input text", lines=3), gr.inputs.Radio(choices=["Hoogelaandsters", "Oldambsters", "Westerkertaaiers"], type="value", default="Hoogelaandsters", label="Variant")],
|
49 |
+
[gr.outputs.Audio(type="filepath", label="Output"), gr.outputs.File()],
|
50 |
title=title,
|
51 |
examples=examples
|
52 |
).launch(enable_queue=True)
|