Spaces:
Runtime error
Runtime error
Commit ·
684979f
1
Parent(s): c6a567c
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
model_name = "facebook/wav2vec2-large-xlsr-53"
|
| 6 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 8 |
|
| 9 |
-
# Define the Gradio interface
|
| 10 |
def text_to_speech(text):
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
speech
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
# Create the Gradio interface
|
| 24 |
-
iface = gr.Interface(fn=text_to_speech, inputs="text", outputs="audio",
|
| 25 |
-
title="Text-to-Speech App",
|
| 26 |
-
description="Enter text to hear the speech")
|
| 27 |
-
|
| 28 |
-
# Launch the Gradio interface
|
| 29 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from IPython.display import Audio
|
| 3 |
+
from transformers import pipeline
|
| 4 |
|
| 5 |
+
pipe = pipeline("text-to-speech", model="suno/bark-small")
|
|
|
|
|
|
|
|
|
|
| 6 |
|
|
|
|
| 7 |
def text_to_speech(text):
|
| 8 |
+
output = pipe(text)
|
| 9 |
+
audio = Audio(output[0]["audio"], rate=output[0]["sampling_rate"])
|
| 10 |
+
return audio
|
| 11 |
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=text_to_speech,
|
| 14 |
+
inputs="text",
|
| 15 |
+
outputs="audio",
|
| 16 |
+
title="Text-to-Speech",
|
| 17 |
+
description="Convert text to speech using Hugging Face's TTS model",
|
| 18 |
+
examples=[
|
| 19 |
+
["Hello, how are you?"],
|
| 20 |
+
["Could you please repeat that?"],
|
| 21 |
+
["This is a test."],
|
| 22 |
+
],
|
| 23 |
+
article="https://huggingface.co/models",
|
| 24 |
+
)
|
| 25 |
|
| 26 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|