Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,24 @@
|
|
1 |
-
# Install
|
2 |
-
# !pip install
|
3 |
|
4 |
-
from
|
5 |
import gradio as gr
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
# Create a gTTS object with Bulgarian language
|
10 |
-
tts = gTTS(text=mytext, lang='bg')
|
11 |
-
# Save the audio file
|
12 |
-
filename = "output.mp3"
|
13 |
-
tts.save(filename)
|
14 |
-
return filename
|
15 |
|
16 |
-
#
|
17 |
-
def
|
18 |
-
|
19 |
-
return
|
20 |
|
21 |
# Create a Gradio interface
|
22 |
iface = gr.Interface(
|
23 |
-
fn=
|
24 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
25 |
-
outputs=gr.Audio(type="file"), #
|
26 |
-
title="Text to Speech Application
|
27 |
-
description="Type your text and
|
28 |
)
|
29 |
|
30 |
# Launch the interface
|
|
|
1 |
+
# Install transformers if not installed
|
2 |
+
# !pip install transformers gradio
|
3 |
|
4 |
+
from transformers import pipeline
|
5 |
import gradio as gr
|
6 |
|
7 |
+
# Load a pre-trained TTS pipeline
|
8 |
+
tts_pipeline = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech")
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
# Function to convert text to audio using the Hugging Face TTS model
|
11 |
+
def text_to_audio(mytext):
|
12 |
+
audio = tts_pipeline(mytext) # Generate audio
|
13 |
+
return audio["filename"] # Return the filename of the generated audio
|
14 |
|
15 |
# Create a Gradio interface
|
16 |
iface = gr.Interface(
|
17 |
+
fn=text_to_audio,
|
18 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
19 |
+
outputs=gr.Audio(type="file"), # Gradio expects a file for audio output
|
20 |
+
title="Text to Speech Application",
|
21 |
+
description="Type your text and generate the corresponding audio."
|
22 |
)
|
23 |
|
24 |
# Launch the interface
|