Spaces:
Runtime error
Runtime error
DaxtonBrandon
commited on
Commit
•
f835a88
1
Parent(s):
255d96a
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
|
|
3 |
|
4 |
def text_to_speech(text):
|
5 |
# Check for specific keywords and modify input text accordingly
|
@@ -10,12 +11,12 @@ def text_to_speech(text):
|
|
10 |
text = text.replace("[music in background]", "")
|
11 |
text = "♫ " + text + " ♫"
|
12 |
|
13 |
-
# Use
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
# Define input text box for Gradio interface
|
21 |
text_input = gr.inputs.Textbox(label="Enter Text")
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
+
from gtts import gTTS
|
4 |
|
5 |
def text_to_speech(text):
|
6 |
# Check for specific keywords and modify input text accordingly
|
|
|
11 |
text = text.replace("[music in background]", "")
|
12 |
text = "♫ " + text + " ♫"
|
13 |
|
14 |
+
# Use gTTS library to generate speech from input text
|
15 |
+
tts = gTTS(text)
|
16 |
+
tts.save("output.mp3")
|
17 |
+
|
18 |
+
# Play the audio file using OS audio player
|
19 |
+
os.system("mpg123 output.mp3")
|
20 |
|
21 |
# Define input text box for Gradio interface
|
22 |
text_input = gr.inputs.Textbox(label="Enter Text")
|