File size: 788 Bytes
477ae85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 in Russian
def text_to_speech(prompt):
    # Convert the input text to speech
    tts = gTTS(prompt, lang="ru")  # 'ru' for Russian
    audio_file = "output.mp3"
    tts.save(audio_file)
    
    return audio_file

# Step 2: Create Gradio interface
with gr.Blocks() as demo:
    gr.Markdown("## Russian Text-to-Speech (TTS)")
    with gr.Row():
        input_prompt = gr.Textbox(label="Enter a prompt in Russian:")
        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()