Spaces:
Sleeping
Sleeping
import gradio as gr | |
from gtts import gTTS | |
# Step 1: Define a function to convert text to speech | |
def text_to_speech(prompt): | |
# Convert the input text to speech | |
tts = gTTS(prompt, lang="bg") # 'bg' for Bulgarian | |
audio_file = "output.mp3" | |
tts.save(audio_file) | |
return audio_file | |
# Step 2: Create Gradio interface | |
with gr.Blocks() as demo: | |
gr.Markdown("## Bulgarian Text-to-Speech (TTS)") | |
with gr.Row(): | |
input_prompt = gr.Textbox(label="Enter a prompt in Bulgarian:") | |
output_audio = gr.Audio(label="Generated Speech", type="filepath") | |
generate_button = gr.Button("Generate Speech") | |
generate_button.click(text_to_speech, inputs=input_prompt, outputs=output_audio) | |
# Run the app | |
if __name__ == "__main__": | |
demo.launch() | |