Update index.html
Browse files- index.html +19 -7
index.html
CHANGED
|
@@ -11,19 +11,31 @@ transformers_js_py
|
|
| 11 |
</gradio-requirements>
|
| 12 |
|
| 13 |
<gradio-file name="app.py" entrypoint>
|
| 14 |
-
from transformers_js import
|
| 15 |
import gradio as gr
|
|
|
|
|
|
|
| 16 |
|
| 17 |
speaker_embeddings = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speaker_embeddings.bin';
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
demo.launch()
|
| 28 |
</gradio-file>
|
| 29 |
|
|
|
|
| 11 |
</gradio-requirements>
|
| 12 |
|
| 13 |
<gradio-file name="app.py" entrypoint>
|
| 14 |
+
from transformers_js import pipeline
|
| 15 |
import gradio as gr
|
| 16 |
+
import numpy as np
|
| 17 |
+
import scipy.io.wavfile as wavfile
|
| 18 |
|
| 19 |
speaker_embeddings = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speaker_embeddings.bin';
|
| 20 |
|
| 21 |
+
async def synthesize(text):
|
| 22 |
+
synthesizer = await pipeline(
|
| 23 |
+
'text-to-speech',
|
| 24 |
+
'Xenova/speecht5_tts',
|
| 25 |
+
{ "quantized": False }
|
| 26 |
+
) # Put the pipeline initializer inside the function to show the first view of the app faster
|
| 27 |
|
| 28 |
+
out = await synthesizer(text, { "speaker_embeddings": speaker_embeddings });
|
| 29 |
+
audio_data_memory_view = out["audio"]
|
| 30 |
+
sampling_rate = out["sampling_rate"]
|
| 31 |
|
| 32 |
+
audio_data = np.frombuffer(audio_data_memory_view, dtype=np.float32)
|
| 33 |
+
|
| 34 |
+
wavfile.write('output.wav', sampling_rate, audio_data)
|
| 35 |
+
return "output.wav"
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
demo = gr.Interface(synthesize, "textbox", "file")
|
| 39 |
demo.launch()
|
| 40 |
</gradio-file>
|
| 41 |
|