Spaces:
Runtime error
Runtime error
Commit
·
4151c7e
1
Parent(s):
1845fa8
Update app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load the text-to-speech pipeline from Hugging Face
|
5 |
-
|
6 |
|
7 |
# Define the Gradio interface
|
8 |
-
def text_to_speech(text
|
9 |
-
#
|
10 |
-
|
11 |
-
voice_model = "facebook/tts-yinipar"
|
12 |
-
elif voice == 'English (UK)':
|
13 |
-
voice_model = "facebook/tts-russell"
|
14 |
-
elif voice == 'French':
|
15 |
-
voice_model = "facebook/wav2vec2-large-xlsr-53-french"
|
16 |
-
elif voice == 'German':
|
17 |
-
voice_model = "facebook/wav2vec2-large-xlsr-53-german"
|
18 |
-
else:
|
19 |
-
voice_model = "facebook/tts-hifigan"
|
20 |
-
|
21 |
-
# Generate speech from the input text using the selected voice model
|
22 |
-
speech = nlp(text, model=voice_model)[0]['audio']
|
23 |
|
24 |
return speech
|
25 |
|
26 |
# Create the Gradio interface
|
27 |
-
iface = gr.Interface(fn=text_to_speech, inputs=
|
28 |
-
|
29 |
-
description="
|
30 |
-
|
31 |
-
# Add voice options to the dropdown input
|
32 |
-
iface.inputs[1].choices = ["English (US)", "English (UK)", "French", "German"]
|
33 |
|
34 |
# Launch the Gradio interface
|
35 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the text-to-speech pipeline from Hugging Face
|
5 |
+
pipe = pipeline("text2speech", model="suno/bark-small")
|
6 |
|
7 |
# Define the Gradio interface
|
8 |
+
def text_to_speech(text):
|
9 |
+
# Generate speech from the input text using the loaded pipeline
|
10 |
+
speech = pipe(text)[0]["speech"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
return speech
|
13 |
|
14 |
# Create the Gradio interface
|
15 |
+
iface = gr.Interface(fn=text_to_speech, inputs="text", outputs="audio",
|
16 |
+
title="Text-to-Speech App",
|
17 |
+
description="Enter text to hear the speech")
|
|
|
|
|
|
|
18 |
|
19 |
# Launch the Gradio interface
|
20 |
iface.launch()
|