Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from gtts import gTTS
|
3 |
+
import os
|
4 |
+
|
5 |
+
def tts_generator(text, selected_voice, pitch, speed):
|
6 |
+
# Generate TTS using gTTS
|
7 |
+
tts = gTTS(text=text, lang='en-us', tld='com', lang_check=False, slow=False)
|
8 |
+
# Save the generated speech as a temporary file
|
9 |
+
temp_file = "temp.mp3"
|
10 |
+
tts.save(temp_file)
|
11 |
+
# Play the generated speech
|
12 |
+
os.system("start " + temp_file)
|
13 |
+
|
14 |
+
# Create a Gradio interface
|
15 |
+
gr.Interface(tts_generator,
|
16 |
+
inputs=[gr.inputs.Textbox(lines=5, label="Enter text to convert to TTS"),
|
17 |
+
gr.inputs.Dropdown(["Male Whisper", "Adult Male #3, American English (TruVoice)"], label="Select Voice"),
|
18 |
+
"number", # Pitch
|
19 |
+
"number"], # Speed
|
20 |
+
outputs=None,
|
21 |
+
title="TTS Generator with Settings",
|
22 |
+
description="Enter text to convert it into Text-to-Speech with customizable settings",
|
23 |
+
theme="compact").launch()
|