Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from gtts import gTTS
|
3 |
+
import os
|
4 |
+
|
5 |
+
def text_to_speech(prompt):
|
6 |
+
# ์
๋ ฅ๋ Bulgarian ํ
์คํธ๋ฅผ ์์ฑ์ผ๋ก ๋ณํ
|
7 |
+
tts = gTTS(text=prompt, lang="bg") # 'bg'๋ Bulgarian ์ธ์ด ์ฝ๋์
๋๋ค.
|
8 |
+
audio_file = "output.mp3"
|
9 |
+
tts.save(audio_file)
|
10 |
+
|
11 |
+
# ํ์ผ ๊ฒฝ๋ก ๋์ ๋ฐ์ด๋๋ฆฌ ๋ฐ์ดํฐ๋ฅผ ๋ฐํํฉ๋๋ค.
|
12 |
+
with open(audio_file, "rb") as f:
|
13 |
+
audio_binary = f.read()
|
14 |
+
# ์์ ํ์ผ ์ญ์
|
15 |
+
os.remove(audio_file)
|
16 |
+
|
17 |
+
return audio_binary
|
18 |
+
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
gr.Markdown("## Bulgarian Text-to-Speech (TTS)")
|
21 |
+
with gr.Row():
|
22 |
+
input_prompt = gr.Textbox(label="Enter a prompt in Bulgarian:")
|
23 |
+
# gr.Audio์ type์ "binary"๋ก ์ง์ ํ์ฌ ํ์ผ ๊ฒฝ๋ก ๋์ ๋ฐ์ด๋๋ฆฌ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
|
24 |
+
output_audio = gr.Audio(label="Generated Speech", type="binary")
|
25 |
+
generate_button = gr.Button("Generate Speech")
|
26 |
+
|
27 |
+
generate_button.click(text_to_speech, inputs=input_prompt, outputs=output_audio)
|
28 |
+
|
29 |
+
if __name__ == "__main__":
|
30 |
+
demo.launch()
|