Spaces:
Sleeping
Sleeping
File size: 783 Bytes
aaae63d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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()
|