Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,25 @@
|
|
1 |
-
from transformers.utils import logging
|
2 |
-
|
3 |
-
logging.set_verbosity_error()
|
4 |
|
5 |
from transformers import pipeline
|
6 |
-
|
7 |
import gradio as gr
|
8 |
-
import os
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
def
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
-
#
|
28 |
-
|
29 |
|
30 |
-
# Launch the Gradio app
|
31 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
1 |
|
2 |
from transformers import pipeline
|
|
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
+
# Initialize the text-to-speech pipeline with a model from Hugging Face's Model Hub
|
6 |
+
model_name = "kakao-enterprise/vits-ljs"
|
7 |
+
text_to_speech_pipeline = pipeline("text-to-speech", model=model_name)
|
8 |
|
9 |
+
def generate_speech(text):
|
10 |
+
# Generate speech from the input text
|
11 |
+
out = text_to_speech_pipeline(text)
|
12 |
+
# The output is a list of tensors, convert to numpy array
|
13 |
+
audio_data = out[0]["array"]
|
14 |
+
return audio_data, 22050 # Return audio data and sampling rate
|
15 |
|
16 |
+
# Create the Gradio interface
|
17 |
+
interface = gr.Interface(fn=generate_speech,
|
18 |
+
inputs=gr.Textbox(lines=2, placeholder="Type something here..."),
|
19 |
+
outputs=gr.Audio(type="numpy", label="Generated Speech"),
|
20 |
+
title="Text-to-Speech with Hugging Face",
|
21 |
+
description="Enter text to generate speech using a model from Hugging Face's Model Hub.")
|
22 |
|
23 |
+
# Launch the app
|
24 |
+
interface.launch()
|
25 |
|
|
|
|