leonelhs commited on
Commit
db34208
·
verified ·
1 Parent(s): ce18f8b

Upload app.py

Browse files

add MCP server

Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -31,10 +31,12 @@
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-82M] - [https://huggingface.co/hexgrad/Kokoro-82M]
35
  # - [Kokoro-onnx] - [https://github.com/thewh1teagle/kokoro-onnx]
36
  # - [Misaki] - [https://github.com/hexgrad/misaki]
37
 
 
38
  import os
39
  import gradio as gr
40
  from misaki import espeak
@@ -62,6 +64,18 @@ voices_path = os.path.join(snapshot, "voices-v1.0.bin")
62
  kokoro = Kokoro(model_path, voices_path)
63
 
64
  def predict(text, voice='ef_dora', speed=1):
 
 
 
 
 
 
 
 
 
 
 
 
65
  phonemes, _ = g2p(text)
66
  samples, sample_rate = kokoro.create(phonemes, voice, speed, is_phonemes=True)
67
  return sample_rate, samples
@@ -77,6 +91,6 @@ app = gr.Interface(
77
  description="Kokoro TTS 🇪🇸 API Endpoint",
78
  )
79
 
80
- app.launch(share=False, debug=True, show_error=True)
81
  app.queue()
82
 
 
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
  # - [Misaki] - [https://github.com/hexgrad/misaki]
38
 
39
+
40
  import os
41
  import gradio as gr
42
  from misaki import espeak
 
64
  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.
72
+ voice (string): The selected male of female voice profile (specific voice ID).
73
+ speed (float): The speaking rate multiplier (e.g., 1.0 = normal speed, 0.8 = slower, 1.2 = faster).
74
+
75
+ Returns:
76
+ path: File path to the generated audio speech.
77
+ """
78
+
79
  phonemes, _ = g2p(text)
80
  samples, sample_rate = kokoro.create(phonemes, voice, speed, is_phonemes=True)
81
  return sample_rate, samples
 
91
  description="Kokoro TTS 🇪🇸 API Endpoint",
92
  )
93
 
94
+ app.launch(share=False, debug=True, show_error=True, mcp_server=True)
95
  app.queue()
96