Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,9 @@ from transformers import pipeline
|
|
| 3 |
|
| 4 |
# Define a list of available speaker models
|
| 5 |
SPEAKER_MODELS = {
|
| 6 |
-
"Default": "
|
| 7 |
-
"Speaker 1": "
|
| 8 |
-
"Speaker 2": "
|
| 9 |
}
|
| 10 |
|
| 11 |
def kokoro_tts(text, speaker):
|
|
@@ -13,7 +13,7 @@ def kokoro_tts(text, speaker):
|
|
| 13 |
tts_pipeline = pipeline("text-to-speech", model=SPEAKER_MODELS[speaker])
|
| 14 |
# Generate speech from text
|
| 15 |
speech = tts_pipeline(text)
|
| 16 |
-
return speech["
|
| 17 |
|
| 18 |
# Create a Gradio interface
|
| 19 |
iface = gr.Interface(
|
|
@@ -24,7 +24,7 @@ iface = gr.Interface(
|
|
| 24 |
],
|
| 25 |
outputs=gr.Audio(label="Generated Speech"),
|
| 26 |
title="Kokoro Text-to-Speech",
|
| 27 |
-
description="A Text-to-Speech app powered by
|
| 28 |
)
|
| 29 |
|
| 30 |
if __name__ == "__main__":
|
|
|
|
| 3 |
|
| 4 |
# Define a list of available speaker models
|
| 5 |
SPEAKER_MODELS = {
|
| 6 |
+
"Default": "onnx-community/Kokoro-82M-ONNX",
|
| 7 |
+
"Speaker 1": "onnx-community/Kokoro-82M-ONNX",
|
| 8 |
+
"Speaker 2": "onnx-community/Kokoro-82M-ONNX"
|
| 9 |
}
|
| 10 |
|
| 11 |
def kokoro_tts(text, speaker):
|
|
|
|
| 13 |
tts_pipeline = pipeline("text-to-speech", model=SPEAKER_MODELS[speaker])
|
| 14 |
# Generate speech from text
|
| 15 |
speech = tts_pipeline(text)
|
| 16 |
+
return speech["audio"]
|
| 17 |
|
| 18 |
# Create a Gradio interface
|
| 19 |
iface = gr.Interface(
|
|
|
|
| 24 |
],
|
| 25 |
outputs=gr.Audio(label="Generated Speech"),
|
| 26 |
title="Kokoro Text-to-Speech",
|
| 27 |
+
description="A Text-to-Speech app powered by Hugging Face Transformers.js with multiple speaker options"
|
| 28 |
)
|
| 29 |
|
| 30 |
if __name__ == "__main__":
|