tts / app.py
Hev832's picture
Create app.py
fefbda7 verified
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()