Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from gtts import gTTS
|
3 |
+
|
4 |
+
# Step 1: Define a function to convert text to speech
|
5 |
+
def text_to_speech(prompt):
|
6 |
+
# Convert the input text to speech
|
7 |
+
tts = gTTS(prompt, lang="bg") # 'bg' for Bulgarian
|
8 |
+
audio_file = "output.mp3"
|
9 |
+
tts.save(audio_file)
|
10 |
+
|
11 |
+
return audio_file
|
12 |
+
|
13 |
+
# Step 2: Create Gradio interface
|
14 |
+
with gr.Blocks() as demo:
|
15 |
+
gr.Markdown("## Bulgarian Text-to-Speech (TTS)")
|
16 |
+
with gr.Row():
|
17 |
+
input_prompt = gr.Textbox(label="Enter a prompt in Bulgarian:")
|
18 |
+
output_audio = gr.Audio(label="Generated Speech", type="filepath")
|
19 |
+
generate_button = gr.Button("Generate Speech")
|
20 |
+
|
21 |
+
generate_button.click(text_to_speech, inputs=input_prompt, outputs=output_audio)
|
22 |
+
|
23 |
+
# Run the app
|
24 |
+
if __name__ == "__main__":
|
25 |
+
demo.launch()
|