Spaces:
Sleeping
Sleeping
gorkemgoknar
commited on
Commit
•
f74bce2
1
Parent(s):
85e94af
Update app.py
Browse filesmicrophone input option
error handling
app.py
CHANGED
@@ -5,14 +5,41 @@ tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1")
|
|
5 |
tts.to("cuda")
|
6 |
|
7 |
|
8 |
-
def predict(prompt, language, audio_file_pth, agree):
|
9 |
if agree == True:
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
return (
|
18 |
gr.make_waveform(
|
@@ -22,6 +49,10 @@ def predict(prompt, language, audio_file_pth, agree):
|
|
22 |
)
|
23 |
else:
|
24 |
gr.Warning("Please accept the Terms & Condition!")
|
|
|
|
|
|
|
|
|
25 |
|
26 |
|
27 |
title = "Coqui🐸 XTTS"
|
@@ -49,21 +80,35 @@ article = """
|
|
49 |
|
50 |
examples = [
|
51 |
[
|
52 |
-
"Once when I was six years old I saw a magnificent picture
|
53 |
"en",
|
54 |
"examples/female.wav",
|
|
|
|
|
55 |
True,
|
56 |
],
|
57 |
[
|
58 |
-
"Lorsque j'avais six ans j'ai vu, une fois, une magnifique image
|
59 |
"fr",
|
60 |
"examples/male.wav",
|
|
|
|
|
61 |
True,
|
62 |
],
|
63 |
[
|
64 |
-
"Un tempo lontano, quando avevo sei anni, vidi un magnifico disegno
|
65 |
"it",
|
66 |
"examples/female.wav",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
True,
|
68 |
],
|
69 |
]
|
@@ -103,6 +148,11 @@ gr.Interface(
|
|
103 |
type="filepath",
|
104 |
value="examples/female.wav",
|
105 |
),
|
|
|
|
|
|
|
|
|
|
|
106 |
gr.Checkbox(
|
107 |
label="Agree",
|
108 |
value=False,
|
|
|
5 |
tts.to("cuda")
|
6 |
|
7 |
|
8 |
+
def predict(prompt, language, audio_file_pth, mic_file_path, use_mic, agree):
|
9 |
if agree == True:
|
10 |
+
if use_mic == True:
|
11 |
+
if mic_file_path is not None:
|
12 |
+
speaker_wav=mic_file_path
|
13 |
+
else:
|
14 |
+
gr.Warning("Please record your voice with Microphone, or uncheck Use Microphone to use reference audios")
|
15 |
+
return (
|
16 |
+
None,
|
17 |
+
None,
|
18 |
+
)
|
19 |
+
|
20 |
+
else:
|
21 |
+
speaker_wav=audio_file_pth
|
22 |
+
|
23 |
+
if len(prompt)<2:
|
24 |
+
gr.Warning("Please give a longer prompt text")
|
25 |
+
return (
|
26 |
+
None,
|
27 |
+
None,
|
28 |
+
)
|
29 |
+
try:
|
30 |
+
tts.tts_to_file(
|
31 |
+
text=prompt,
|
32 |
+
file_path="output.wav",
|
33 |
+
speaker_wav=speaker_wav,
|
34 |
+
language=language,
|
35 |
+
)
|
36 |
+
except RuntimeError:
|
37 |
+
if "device-side" in e.message:
|
38 |
+
# cannot do anything on cuda device side error, need tor estart
|
39 |
+
gr.Warning("Unhandled Exception encounter, please retry in a minute")
|
40 |
+
print("Cuda device-assert Runtime encountered need restart")
|
41 |
+
sys.exit("Exit due to cuda device-assert")
|
42 |
+
raise
|
43 |
|
44 |
return (
|
45 |
gr.make_waveform(
|
|
|
49 |
)
|
50 |
else:
|
51 |
gr.Warning("Please accept the Terms & Condition!")
|
52 |
+
return (
|
53 |
+
None,
|
54 |
+
None,
|
55 |
+
)
|
56 |
|
57 |
|
58 |
title = "Coqui🐸 XTTS"
|
|
|
80 |
|
81 |
examples = [
|
82 |
[
|
83 |
+
"Once when I was six years old I saw a magnificent picture",
|
84 |
"en",
|
85 |
"examples/female.wav",
|
86 |
+
None,
|
87 |
+
False,
|
88 |
True,
|
89 |
],
|
90 |
[
|
91 |
+
"Lorsque j'avais six ans j'ai vu, une fois, une magnifique image",
|
92 |
"fr",
|
93 |
"examples/male.wav",
|
94 |
+
None,
|
95 |
+
False,
|
96 |
True,
|
97 |
],
|
98 |
[
|
99 |
+
"Un tempo lontano, quando avevo sei anni, vidi un magnifico disegno",
|
100 |
"it",
|
101 |
"examples/female.wav",
|
102 |
+
None,
|
103 |
+
False,
|
104 |
+
True,
|
105 |
+
],
|
106 |
+
[
|
107 |
+
"Bir zamanlar, altı yaşındayken, muhteşem bir resim gördüm",
|
108 |
+
"tr",
|
109 |
+
"examples/female.wav",
|
110 |
+
None,
|
111 |
+
False,
|
112 |
True,
|
113 |
],
|
114 |
]
|
|
|
148 |
type="filepath",
|
149 |
value="examples/female.wav",
|
150 |
),
|
151 |
+
gr.Audio(source="microphone",
|
152 |
+
type="filepath",
|
153 |
+
info="Use your microphone to record audio",
|
154 |
+
label="Use Microphone for Reference"),
|
155 |
+
gr.Checkbox(label="Check to use Microphone as Reference", value=False),
|
156 |
gr.Checkbox(
|
157 |
label="Agree",
|
158 |
value=False,
|