Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,40 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
|
4 |
-
import numpy as np
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
"facebook/tts_transformer-zh-cv7_css10", # Considere usar um modelo para inglês
|
9 |
-
arg_overrides={"vocoder": "hifigan", "fp16": False}
|
10 |
-
)
|
11 |
-
model = models[0]
|
12 |
-
TTSHubInterface.update_cfg_with_data_cfg(cfg, task.data_cfg)
|
13 |
-
generator = task.build_generator(model, cfg)
|
14 |
-
return task, model, generator
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
["Hello, how are you today?"],
|
26 |
-
["What's the weather like?"],
|
27 |
-
["Learning new languages is fun."],
|
28 |
-
# Adicione mais exemplos aqui
|
29 |
-
]
|
30 |
-
|
31 |
-
iface = gr.Interface(
|
32 |
-
fn=synthesize_text,
|
33 |
-
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter English text here..."),
|
34 |
-
outputs=gr.outputs.Audio(label="Synthesized Speech"),
|
35 |
-
title="Text to Speech Synthesis",
|
36 |
-
description="A simple text-to-speech app. Note: The model is trained for Chinese, results may vary for English.",
|
37 |
-
examples=examples,
|
38 |
-
theme="huggingface"
|
39 |
)
|
40 |
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
|
|
|
|
3 |
|
4 |
+
# Initialize the pipeline
|
5 |
+
pipe = pipeline("text-to-speech", model="suno/bark-small")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
# Define a function to handle the text-to-speech conversion
|
8 |
+
def text_to_speech(text):
|
9 |
+
output = pipe(text)
|
10 |
+
# Assuming the output is a sound file, we return the path to the sound file
|
11 |
+
return output['path']
|
12 |
|
13 |
+
# Create a Gradio interface
|
14 |
+
interface = gr.Interface(
|
15 |
+
fn=text_to_speech,
|
16 |
+
inputs="text",
|
17 |
+
outputs="audio",
|
18 |
+
title="Text-to-Speech App",
|
19 |
+
description="Convert text to speech using Hugging Face's Transformers"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
)
|
21 |
|
22 |
+
# Launch the app
|
23 |
+
if __name__ == "__main__":
|
24 |
+
interface.launch()
|