Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
|
4 |
-
|
5 |
-
model_name = "facebook/wav2vec2-base-960h"
|
6 |
-
tts_model = Text2SpeechForConditionalGeneration.from_pretrained(model_name)
|
7 |
-
tokenizer = Text2SpeechTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
def text_to_speech(text):
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
iface = gr.Interface(fn=text_to_speech, inputs="text", outputs="audio")
|
16 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from gtts import gTTS
|
3 |
+
import tempfile
|
4 |
+
import os
|
|
|
|
|
|
|
5 |
|
6 |
def text_to_speech(text):
|
7 |
+
tts = gTTS(text=text, lang='en')
|
8 |
+
_, temp_path = tempfile.mkstemp(suffix=".mp3")
|
9 |
+
tts.save(temp_path)
|
10 |
+
return temp_path
|
11 |
|
12 |
iface = gr.Interface(fn=text_to_speech, inputs="text", outputs="audio")
|
13 |
iface.launch()
|