Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
|
| 6 |
+
tts = pipeline(task="text-to-speech", model="facebook/mms-tts-eng")
|
| 7 |
+
|
| 8 |
+
def run_tts(txt):
|
| 9 |
+
res = tts(txt)
|
| 10 |
+
audio = (res['audio'].reshape(-1) * 2 ** 15).astype(np.int16)
|
| 11 |
+
return res['sampling_rate'], audio
|
| 12 |
+
|
| 13 |
+
with gr.Blocks() as demo:
|
| 14 |
+
gr.Interface(
|
| 15 |
+
run_tts,
|
| 16 |
+
inputs=gr.Textbox(),
|
| 17 |
+
outputs="audio",
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
demo.launch()
|