Spaces:
Running
Running
alonsosilva
commited on
Commit
·
3353157
1
Parent(s):
8b05d66
Upload app
Browse files- Dockerfile +21 -0
- README.md +0 -2
- app.py +48 -0
- kokoro-quant.onnx +3 -0
- kokoro-v0_19.onnx +3 -0
- requirements.txt +3 -0
- voices.bin +3 -0
Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.12
|
2 |
+
COPY --from=ghcr.io/astral-sh/uv:0.4.20 /uv /bin/uv
|
3 |
+
|
4 |
+
# Set up a new user named "user" with user ID 1000
|
5 |
+
RUN useradd -m -u 1000 user
|
6 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
7 |
+
ENV UV_SYSTEM_PYTHON=1
|
8 |
+
|
9 |
+
WORKDIR /app
|
10 |
+
|
11 |
+
COPY --chown=user ./kokoro-quant.onnx kokoro-quant.onnx
|
12 |
+
COPY --chown=user ./kokoro-v0_19.onnx kokoro-v0_19.onnx
|
13 |
+
COPY --chown=user ./voices.bin voices.bin
|
14 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
15 |
+
RUN uv pip install -r requirements.txt
|
16 |
+
|
17 |
+
COPY --chown=user . /app
|
18 |
+
# Switch to the "user" user
|
19 |
+
USER user
|
20 |
+
|
21 |
+
CMD ["solara", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
@@ -8,5 +8,3 @@ pinned: false
|
|
8 |
license: apache-2.0
|
9 |
short_description: Kokoro Text-to-Speech
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
8 |
license: apache-2.0
|
9 |
short_description: Kokoro Text-to-Speech
|
10 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
import solara
|
3 |
+
import soundfile as sf
|
4 |
+
from kokoro_onnx import Kokoro
|
5 |
+
from IPython.display import display, Audio
|
6 |
+
|
7 |
+
text = solara.reactive("")
|
8 |
+
|
9 |
+
@solara.component
|
10 |
+
def Example(example: str, example_shortened=None):
|
11 |
+
def on_click():
|
12 |
+
text.value = example
|
13 |
+
with solara.Row():
|
14 |
+
solara.Button(example, on_click=on_click)
|
15 |
+
|
16 |
+
|
17 |
+
models = ["kokoro-v0_19.onnx", "kokoro-quant.onnx"]
|
18 |
+
model = solara.reactive("kokoro-v0_19.onnx")
|
19 |
+
voices = ["af", "af_bella", "af_nicole", "af_sarah", "af_sky", "am_adam", "am_michael", "bf_emma", "bf_isabella", "bm_george", "bm_lewis"]
|
20 |
+
voice = solara.reactive("af_sarah")
|
21 |
+
|
22 |
+
generate = solara.reactive(False)
|
23 |
+
@solara.component
|
24 |
+
def Page():
|
25 |
+
title = "Kokoro Text-To-Speech"
|
26 |
+
with solara.Head():
|
27 |
+
solara.Title(f"{title}")
|
28 |
+
with solara.Column(style={"width": "100%", "padding": "50px", "align": "center"}):
|
29 |
+
solara.Markdown(f"#{title}")
|
30 |
+
solara.Markdown("Try some examples:")
|
31 |
+
with solara.Row():
|
32 |
+
Example("Hello! How can I assist you today?")
|
33 |
+
Example("The capital of France is Paris.")
|
34 |
+
solara.Markdown("Or write your own:")
|
35 |
+
solara.InputTextArea("Enter some text", value=text, rows=3, continuous_update=False)
|
36 |
+
with solara.Row():
|
37 |
+
solara.Select(label="Select voice:", value=voice, values=voices, style={"width": "10%"})
|
38 |
+
solara.Select(label="Select model:", value=model, values=models, style={"width": "10%"})
|
39 |
+
solara.Button("Generate", on_click=generate.set(True))
|
40 |
+
solara.Button("Clear", on_click=lambda: text.set(""))
|
41 |
+
kokoro = Kokoro(model.value, "voices.bin")
|
42 |
+
if text.value != "" and generate.value:
|
43 |
+
start_time = time.time()
|
44 |
+
samples, sample_rate = kokoro.create(text.value, voice=voice.value, speed=1.0)
|
45 |
+
end_time = time.time()
|
46 |
+
display(Audio(data=samples, rate=sample_rate, autoplay=True))
|
47 |
+
solara.Text(f"Generation time: {end_time - start_time:.1f} seconds", style="color: blue")
|
48 |
+
|
kokoro-quant.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d7fe30313cc305d3290aafc748ac02a28f93cabd76702bdb1c5ebea496d4cad
|
3 |
+
size 177465355
|
kokoro-v0_19.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ebef42457f7efee9b60b4f1d5aec7692f2925923948a0d7a2a49d2c9edf57e49
|
3 |
+
size 345554732
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
kokoro-onnx
|
2 |
+
soundfile
|
3 |
+
solara
|
voices.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:157eab2fa1dd1c91b46599ea6f514bf86f66944c0c760250ed324e6cd99af075
|
3 |
+
size 5758648
|