Update index.html
Browse files- index.html +30 -39
index.html
CHANGED
|
@@ -1,57 +1,48 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
-
<meta charset="utf-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
-
<title>Gradio-Lite: Serverless Gradio Running Entirely in Your Browser</title>
|
| 7 |
-
<meta name="description" content="Gradio-Lite: Serverless Gradio Running Entirely in Your Browser">
|
| 8 |
-
|
| 9 |
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
|
| 10 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
|
| 11 |
-
|
| 12 |
-
<style>
|
| 13 |
-
html, body {
|
| 14 |
-
margin: 0;
|
| 15 |
-
padding: 0;
|
| 16 |
-
height: 100%;
|
| 17 |
-
}
|
| 18 |
-
</style>
|
| 19 |
</head>
|
| 20 |
<body>
|
| 21 |
-
|
| 22 |
-
<gradio-file name="app.py" entrypoint>
|
| 23 |
-
import gradio as gr
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
return output_image
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
"
|
| 35 |
-
examples=["lion.jpg", "logo.png"],
|
| 36 |
)
|
|
|
|
| 37 |
|
| 38 |
-
demo.launch()
|
| 39 |
-
</gradio-file>
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
def as_gray(image):
|
| 45 |
-
return rgb2gray(image)
|
| 46 |
-
</gradio-file>
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
<gradio-requirements>
|
| 52 |
-
# Same syntax as requirements.txt
|
| 53 |
-
scikit-image
|
| 54 |
-
</gradio-requirements>
|
| 55 |
-
</gradio-lite>
|
| 56 |
</body>
|
| 57 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
|
| 5 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
</head>
|
| 7 |
<body>
|
| 8 |
+
<gradio-lite>
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
<gradio-requirements>
|
| 11 |
+
transformers_js_py
|
| 12 |
+
</gradio-requirements>
|
| 13 |
+
|
| 14 |
+
<gradio-file name="app.py" entrypoint>
|
| 15 |
+
from transformers_js_py import import_transformers_js
|
| 16 |
+
import gradio as gr
|
| 17 |
+
import numpy as np
|
| 18 |
|
| 19 |
+
transformers_js = await import_transformers_js("3.0.2")
|
| 20 |
+
pipeline = transformers_js.pipeline
|
|
|
|
| 21 |
|
| 22 |
+
synthesizer = await pipeline(
|
| 23 |
+
'text-to-speech',
|
| 24 |
+
'Xenova/speecht5_tts',
|
| 25 |
+
{ "quantized": False }
|
|
|
|
| 26 |
)
|
| 27 |
+
speaker_embeddings = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speaker_embeddings.bin';
|
| 28 |
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
async def synthesize(text):
|
| 31 |
+
out = await synthesizer(text, { "speaker_embeddings": speaker_embeddings });
|
| 32 |
+
audio_data_memory_view = out["audio"]
|
| 33 |
+
sampling_rate = out["sampling_rate"]
|
| 34 |
+
|
| 35 |
+
audio_data = np.frombuffer(audio_data_memory_view, dtype=np.float32)
|
| 36 |
+
audio_data_16bit = (audio_data * 32767).astype(np.int16)
|
| 37 |
+
|
| 38 |
+
return sampling_rate, audio_data_16bit
|
| 39 |
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
demo = gr.Interface(synthesize, "textbox", "audio")
|
| 42 |
+
demo.launch()
|
| 43 |
+
</gradio-file>
|
| 44 |
+
|
| 45 |
+
</gradio-lite>
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
</body>
|
| 48 |
</html>
|