File size: 957 Bytes
fefbda7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from gtts import gTTS
import os

def tts_generator(text, selected_voice, pitch, speed):
    # Generate TTS using gTTS
    tts = gTTS(text=text, lang='en-us', tld='com', lang_check=False, slow=False)
    # Save the generated speech as a temporary file
    temp_file = "temp.mp3"
    tts.save(temp_file)
    # Play the generated speech
    os.system("start " + temp_file)

# Create a Gradio interface
gr.Interface(tts_generator, 
             inputs=[gr.inputs.Textbox(lines=5, label="Enter text to convert to TTS"),
                     gr.inputs.Dropdown(["Male Whisper", "Adult Male #3, American English (TruVoice)"], label="Select Voice"),
                     "number", # Pitch
                     "number"], # Speed
             outputs=None,
             title="TTS Generator with Settings",
             description="Enter text to convert it into Text-to-Speech with customizable settings",
             theme="compact").launch()