Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,20 +3,22 @@ from gtts import gTTS
|
|
3 |
import tempfile
|
4 |
import os
|
5 |
|
6 |
-
def text_to_speech(text, language
|
7 |
tts = gTTS(text, lang=language)
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
|
12 |
# Gradio μΈν°νμ΄μ€λ₯Ό μμ±ν©λλ€.
|
13 |
iface = gr.Interface(
|
14 |
fn=text_to_speech,
|
15 |
inputs=[
|
16 |
-
gr.Textbox(lines=2, placeholder="
|
17 |
-
gr.Dropdown(label="
|
18 |
],
|
19 |
-
outputs=gr.Audio(type="filepath", label="
|
20 |
)
|
21 |
|
22 |
# μΈν°νμ΄μ€λ₯Ό μ€νν©λλ€.
|
|
|
3 |
import tempfile
|
4 |
import os
|
5 |
|
6 |
+
def text_to_speech(text, language):
|
7 |
tts = gTTS(text, lang=language)
|
8 |
+
# μμ νμΌμ μμ±νκ³ MP3 νμΌμ μ μ₯ν©λλ€.
|
9 |
+
temp_file = tempfile.NamedTemporaryFile(suffix='.mp3', delete=False)
|
10 |
+
tts.save(temp_file.name)
|
11 |
+
temp_file.close() # νμΌμ λ«κ³ μ€μ κ²½λ‘λ₯Ό λ°νν©λλ€.
|
12 |
+
return temp_file.name
|
13 |
|
14 |
# Gradio μΈν°νμ΄μ€λ₯Ό μμ±ν©λλ€.
|
15 |
iface = gr.Interface(
|
16 |
fn=text_to_speech,
|
17 |
inputs=[
|
18 |
+
gr.Textbox(lines=2, placeholder="μμ± μμ±μ μν΄ ν
μ€νΈλ₯Ό μ
λ ₯νμΈμ"),
|
19 |
+
gr.Dropdown(label="μΈμ΄ μ ν", choices=["en", "es", "de", "fr", "ko"], default="ko"),
|
20 |
],
|
21 |
+
outputs=gr.Audio(type="filepath", label="μμ±λ μμ±"),
|
22 |
)
|
23 |
|
24 |
# μΈν°νμ΄μ€λ₯Ό μ€νν©λλ€.
|