Spaces:
Sleeping
Sleeping
shiveshnavin
commited on
Commit
•
617d161
1
Parent(s):
1a4ba15
Update
Browse files- .vscode/settings.json +6 -0
- app.py +24 -6
- output.wav +0 -0
.vscode/settings.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"[python]": {
|
3 |
+
"editor.defaultFormatter": "ms-python.black-formatter"
|
4 |
+
},
|
5 |
+
"python.formatting.provider": "none"
|
6 |
+
}
|
app.py
CHANGED
@@ -1,16 +1,34 @@
|
|
1 |
import gradio as gr
|
2 |
from TTS.api import TTS
|
|
|
|
|
3 |
|
4 |
-
model_name =
|
5 |
-
promisingM = [
|
6 |
-
promisingF = [
|
7 |
speakers = promisingM + promisingF
|
8 |
tts = TTS(model_name)
|
9 |
|
|
|
10 |
def text_to_speech(sentence, speaker_name):
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
return wav
|
13 |
|
|
|
14 |
iface = gr.Interface(
|
15 |
fn=text_to_speech,
|
16 |
inputs=["text", "text"],
|
@@ -20,8 +38,8 @@ iface = gr.Interface(
|
|
20 |
examples=[
|
21 |
["Hello, this is a sample sentence.", "p282"],
|
22 |
["How are you doing?", "p301"],
|
23 |
-
]
|
24 |
)
|
25 |
|
26 |
if __name__ == "__main__":
|
27 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from TTS.api import TTS
|
3 |
+
import tempfile
|
4 |
+
import os
|
5 |
|
6 |
+
model_name = "tts_models/en/vctk/vits"
|
7 |
+
promisingM = ["p282", "p301", "p234", "p232", "p256", "p267", "p272"]
|
8 |
+
promisingF = ["p311", "p361", "p263", "p306", "p259"]
|
9 |
speakers = promisingM + promisingF
|
10 |
tts = TTS(model_name)
|
11 |
|
12 |
+
|
13 |
def text_to_speech(sentence, speaker_name):
|
14 |
+
file = tempfile.NamedTemporaryFile(
|
15 |
+
mode="w+b",
|
16 |
+
buffering=-1,
|
17 |
+
encoding=None,
|
18 |
+
newline=None,
|
19 |
+
suffix=None,
|
20 |
+
prefix=None,
|
21 |
+
dir=None,
|
22 |
+
delete=False,
|
23 |
+
).name
|
24 |
+
wav = tts.tts_to_file(
|
25 |
+
text=sentence, speaker=speaker_name, file_path=file, verbose=False
|
26 |
+
)
|
27 |
+
with open(wav, "rb") as audio_file:
|
28 |
+
audio_data = audio_file.read()
|
29 |
return wav
|
30 |
|
31 |
+
|
32 |
iface = gr.Interface(
|
33 |
fn=text_to_speech,
|
34 |
inputs=["text", "text"],
|
|
|
38 |
examples=[
|
39 |
["Hello, this is a sample sentence.", "p282"],
|
40 |
["How are you doing?", "p301"],
|
41 |
+
],
|
42 |
)
|
43 |
|
44 |
if __name__ == "__main__":
|
45 |
+
iface.launch(enable_queue=True)
|
output.wav
ADDED
File without changes
|