Spaces:
Running
Running
Italian mode
Browse filesCreated Italian API
app.py
CHANGED
|
@@ -24,17 +24,18 @@
|
|
| 24 |
#
|
| 25 |
#######################################################################################
|
| 26 |
|
| 27 |
-
# This file implements an API endpoint for the
|
| 28 |
-
# It provides functionality to generate TTS audio from input
|
| 29 |
|
| 30 |
|
| 31 |
# Source code is based on or inspired by several projects.
|
| 32 |
# For more details and proper attribution, please refer to the following resources:
|
| 33 |
#
|
| 34 |
# - [Kokoro] - [https://github.com/hexgrad/kokoro]
|
|
|
|
| 35 |
# - [Kokoro-82M] - [https://huggingface.co/hexgrad/Kokoro-82M]
|
| 36 |
# - [Kokoro-onnx] - [https://github.com/thewh1teagle/kokoro-onnx]
|
| 37 |
-
|
| 38 |
|
| 39 |
|
| 40 |
import os
|
|
@@ -47,16 +48,15 @@ from huggingface_hub import snapshot_download
|
|
| 47 |
KOKORO_REPO_ID = "leonelhs/kokoro-thewh1teagle"
|
| 48 |
|
| 49 |
VOICES = {
|
| 50 |
-
'🚺
|
| 51 |
-
'🚹
|
| 52 |
-
'🚹 Santa':'em_santa'
|
| 53 |
}
|
| 54 |
|
| 55 |
snapshot = snapshot_download(repo_id=KOKORO_REPO_ID)
|
| 56 |
|
| 57 |
# Misaki G2P with espeak-ng fallback
|
| 58 |
fallback = espeak.EspeakFallback(british=False)
|
| 59 |
-
g2p = EspeakG2P(language="
|
| 60 |
|
| 61 |
# Kokoro
|
| 62 |
model_path = os.path.join(snapshot, "kokoro-v1.0.onnx")
|
|
@@ -65,7 +65,7 @@ kokoro = Kokoro(model_path, voices_path)
|
|
| 65 |
|
| 66 |
def predict(text, voice='ef_dora', speed=1):
|
| 67 |
"""
|
| 68 |
-
Generate speech audio from text input.
|
| 69 |
|
| 70 |
Parameters:
|
| 71 |
text (string): The text to be converted into speech.
|
|
@@ -88,7 +88,7 @@ app = gr.Interface(
|
|
| 88 |
gr.Slider(minimum=0.5, maximum=2, value=1, step=0.1, label='Speed')
|
| 89 |
],
|
| 90 |
gr.Audio(label='Output Audio', interactive=False, streaming=False, autoplay=True),
|
| 91 |
-
description="Kokoro TTS
|
| 92 |
)
|
| 93 |
|
| 94 |
app.launch(share=False, debug=True, show_error=True, mcp_server=True)
|
|
|
|
| 24 |
#
|
| 25 |
#######################################################################################
|
| 26 |
|
| 27 |
+
# This file implements an API endpoint for the Italian Kokoro Text-to-Speech (TTS) system.
|
| 28 |
+
# It provides functionality to generate TTS audio from input Italian text using the Kokoro voice model.
|
| 29 |
|
| 30 |
|
| 31 |
# Source code is based on or inspired by several projects.
|
| 32 |
# For more details and proper attribution, please refer to the following resources:
|
| 33 |
#
|
| 34 |
# - [Kokoro] - [https://github.com/hexgrad/kokoro]
|
| 35 |
+
# - [Misaki] - [https://github.com/hexgrad/misaki]
|
| 36 |
# - [Kokoro-82M] - [https://huggingface.co/hexgrad/Kokoro-82M]
|
| 37 |
# - [Kokoro-onnx] - [https://github.com/thewh1teagle/kokoro-onnx]
|
| 38 |
+
|
| 39 |
|
| 40 |
|
| 41 |
import os
|
|
|
|
| 48 |
KOKORO_REPO_ID = "leonelhs/kokoro-thewh1teagle"
|
| 49 |
|
| 50 |
VOICES = {
|
| 51 |
+
'🚺 Sara':'if_sara',
|
| 52 |
+
'🚹 Nicola':'im_nicola'
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
snapshot = snapshot_download(repo_id=KOKORO_REPO_ID)
|
| 56 |
|
| 57 |
# Misaki G2P with espeak-ng fallback
|
| 58 |
fallback = espeak.EspeakFallback(british=False)
|
| 59 |
+
g2p = EspeakG2P(language="it")
|
| 60 |
|
| 61 |
# Kokoro
|
| 62 |
model_path = os.path.join(snapshot, "kokoro-v1.0.onnx")
|
|
|
|
| 65 |
|
| 66 |
def predict(text, voice='ef_dora', speed=1):
|
| 67 |
"""
|
| 68 |
+
Generate speech audio from italian text input.
|
| 69 |
|
| 70 |
Parameters:
|
| 71 |
text (string): The text to be converted into speech.
|
|
|
|
| 88 |
gr.Slider(minimum=0.5, maximum=2, value=1, step=0.1, label='Speed')
|
| 89 |
],
|
| 90 |
gr.Audio(label='Output Audio', interactive=False, streaming=False, autoplay=True),
|
| 91 |
+
description="Kokoro TTS 🇮🇹 API Endpoint",
|
| 92 |
)
|
| 93 |
|
| 94 |
app.launch(share=False, debug=True, show_error=True, mcp_server=True)
|