Spaces:
Runtime error
Runtime error
Upload proyecto1.py
Browse files- proyecto1.py +22 -0
proyecto1.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import scipy
|
| 4 |
+
|
| 5 |
+
def getText(text):
|
| 6 |
+
return text
|
| 7 |
+
|
| 8 |
+
def say_something(text):
|
| 9 |
+
synthesiser = pipeline("text-to-speech", "suno/bark-small")
|
| 10 |
+
speech = synthesiser("Hello world!", forward_params={"do_sample": True})
|
| 11 |
+
scipy.io.wavfile.write("bark_out.wav", rate=speech["sampling_rate"], data=speech["audio"])
|
| 12 |
+
return "bark_out.wav"
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
with gr.Blocks() as demo:
|
| 16 |
+
textBox = gr.Textbox(label="Text")
|
| 17 |
+
button = gr.Button("Generate Speech")
|
| 18 |
+
audio_output = gr.Audio(label="Generated Speech")
|
| 19 |
+
button.click( say_something, outputs=[audio_output])
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
demo.launch()
|