leonelhs commited on
Commit
3330cce
ยท
verified ยท
1 Parent(s): 6ed3bdc

Update app.py

Browse files

Init hindi version

Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -24,17 +24,18 @@
24
  #
25
  #######################################################################################
26
 
27
- # This file implements an API endpoint for the Spanish Kokoro Text-to-Speech (TTS) system.
28
- # It provides functionality to generate TTS audio from input Spanish 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
  # - [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
@@ -47,25 +48,26 @@ from huggingface_hub import snapshot_download
47
  KOKORO_REPO_ID = "leonelhs/kokoro-thewh1teagle"
48
 
49
  VOICES = {
50
- '๐Ÿšบ Dora':'ef_dora',
51
- '๐Ÿšน Alex':'em_alex',
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="es")
60
 
61
  # Kokoro
62
  model_path = os.path.join(snapshot, "kokoro-v1.0.onnx")
63
  voices_path = os.path.join(snapshot, "voices-v1.0.bin")
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.
@@ -84,11 +86,11 @@ app = gr.Interface(
84
  predict,
85
  [
86
  gr.Textbox(label='Input Text'),
87
- gr.Dropdown(list(VOICES.items()), value='ef_dora', label='Voice'),
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)
 
24
  #
25
  #######################################################################################
26
 
27
+ # This file implements an API endpoint for the Hindi Kokoro Text-to-Speech (TTS) system.
28
+ # It provides functionality to generate TTS audio from input Hindi 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
+ '๐Ÿšบ Alpha':'hf_alpha',
52
+ '๐Ÿšบ Beta':'hf_beta',
53
+ '๐Ÿšน Omega':'hm_omega',
54
+ '๐Ÿšน Psi':'hm_psi'
55
  }
56
 
57
  snapshot = snapshot_download(repo_id=KOKORO_REPO_ID)
58
 
59
  # Misaki G2P with espeak-ng fallback
60
  fallback = espeak.EspeakFallback(british=False)
61
+ g2p = EspeakG2P(language="hi")
62
 
63
  # Kokoro
64
  model_path = os.path.join(snapshot, "kokoro-v1.0.onnx")
65
  voices_path = os.path.join(snapshot, "voices-v1.0.bin")
66
  kokoro = Kokoro(model_path, voices_path)
67
 
68
+ def predict(text, voice='hf_alpha', speed=1):
69
  """
70
+ Generate speech audio from hindi text input.
71
 
72
  Parameters:
73
  text (string): The text to be converted into speech.
 
86
  predict,
87
  [
88
  gr.Textbox(label='Input Text'),
89
+ gr.Dropdown(list(VOICES.items()), value='hf_alpha', label='Voice'),
90
  gr.Slider(minimum=0.5, maximum=2, value=1, step=0.1, label='Speed')
91
  ],
92
  gr.Audio(label='Output Audio', interactive=False, streaming=False, autoplay=True),
93
+ description="Kokoro TTS ๐Ÿ‡ฎ๐Ÿ‡ณ API Endpoint",
94
  )
95
 
96
  app.launch(share=False, debug=True, show_error=True, mcp_server=True)