Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ if not IS_DUPLICATE:
|
|
| 16 |
|
| 17 |
CHAR_LIMIT = None if IS_DUPLICATE else 5000
|
| 18 |
models = {gpu: KModel().to('cuda' if gpu else 'cpu').eval() for gpu in [False] + ([True] if CUDA_AVAILABLE else [])}
|
| 19 |
-
pipelines = {lang_code: KPipeline(lang_code=lang_code, model=False) for lang_code in '
|
| 20 |
pipelines['a'].g2p.lexicon.golds['kokoro'] = 'kˈOkəɹO'
|
| 21 |
pipelines['b'].g2p.lexicon.golds['kokoro'] = 'kˈQkəɹQ'
|
| 22 |
|
|
@@ -68,6 +68,7 @@ def tokenize_first(text, voice='af_heart'):
|
|
| 68 |
return ''
|
| 69 |
|
| 70 |
def generate_all(text, voice='af_heart', speed=1, use_gpu=CUDA_AVAILABLE):
|
|
|
|
| 71 |
text = text if CHAR_LIMIT is None else text.strip()[:CHAR_LIMIT]
|
| 72 |
pipeline = pipelines[voice[0]]
|
| 73 |
pack = pipeline.load_voice(voice)
|
|
@@ -135,11 +136,11 @@ CHOICES = {
|
|
| 135 |
'🇬🇧 🚹 Fable': 'bm_fable',
|
| 136 |
'🇬🇧 🚹 Lewis': 'bm_lewis',
|
| 137 |
'🇬🇧 🚹 Daniel': 'bm_daniel',
|
| 138 |
-
'Espanol':'ef_dora',
|
| 139 |
-
'Hindi':'hf_alpha',
|
| 140 |
-
'French':'ff_siwis',
|
| 141 |
-
'Italian':'if_sara',
|
| 142 |
-
'Portuguese':'pf_dora',
|
| 143 |
}
|
| 144 |
for v in CHOICES.values():
|
| 145 |
pipelines[v[0]].load_voice(v)
|
|
@@ -154,6 +155,8 @@ TOKEN_NOTE = '''
|
|
| 154 |
⬆️ Raise stress 1 level `[or](+2)` 2 levels (only works on less stressed, usually short words)
|
| 155 |
'''
|
| 156 |
|
|
|
|
|
|
|
| 157 |
with gr.Blocks() as generate_tab:
|
| 158 |
out_audio = gr.Audio(label='Output Audio', interactive=False, streaming=False, autoplay=True)
|
| 159 |
generate_btn = gr.Button('Generate', variant='primary')
|
|
@@ -181,7 +184,7 @@ with gr.Blocks() as stream_tab:
|
|
| 181 |
BANNER_TEXT = '''
|
| 182 |
[***Kokoro*** **is an open-weight TTS model with 82 million parameters.**](https://huggingface.co/hexgrad/Kokoro-82M)
|
| 183 |
|
| 184 |
-
This demo showcases Indonesian with English accent
|
| 185 |
'''
|
| 186 |
API_OPEN = os.getenv('SPACE_ID') != 'hexgrad/Kokoro-TTS'
|
| 187 |
API_NAME = None if API_OPEN else False
|
|
|
|
| 16 |
|
| 17 |
CHAR_LIMIT = None if IS_DUPLICATE else 5000
|
| 18 |
models = {gpu: KModel().to('cuda' if gpu else 'cpu').eval() for gpu in [False] + ([True] if CUDA_AVAILABLE else [])}
|
| 19 |
+
pipelines = {lang_code: KPipeline(lang_code=lang_code, model=False) for lang_code in 'ab'}
|
| 20 |
pipelines['a'].g2p.lexicon.golds['kokoro'] = 'kˈOkəɹO'
|
| 21 |
pipelines['b'].g2p.lexicon.golds['kokoro'] = 'kˈQkəɹQ'
|
| 22 |
|
|
|
|
| 68 |
return ''
|
| 69 |
|
| 70 |
def generate_all(text, voice='af_heart', speed=1, use_gpu=CUDA_AVAILABLE):
|
| 71 |
+
text = f"[_](/{indo_to_ipa(text)}/)"
|
| 72 |
text = text if CHAR_LIMIT is None else text.strip()[:CHAR_LIMIT]
|
| 73 |
pipeline = pipelines[voice[0]]
|
| 74 |
pack = pipeline.load_voice(voice)
|
|
|
|
| 136 |
'🇬🇧 🚹 Fable': 'bm_fable',
|
| 137 |
'🇬🇧 🚹 Lewis': 'bm_lewis',
|
| 138 |
'🇬🇧 🚹 Daniel': 'bm_daniel',
|
| 139 |
+
# 'Espanol':'ef_dora',
|
| 140 |
+
# 'Hindi':'hf_alpha',
|
| 141 |
+
# 'French':'ff_siwis',
|
| 142 |
+
# 'Italian':'if_sara',
|
| 143 |
+
# 'Portuguese':'pf_dora',
|
| 144 |
}
|
| 145 |
for v in CHOICES.values():
|
| 146 |
pipelines[v[0]].load_voice(v)
|
|
|
|
| 155 |
⬆️ Raise stress 1 level `[or](+2)` 2 levels (only works on less stressed, usually short words)
|
| 156 |
'''
|
| 157 |
|
| 158 |
+
TOKEN_NOTE = ""
|
| 159 |
+
|
| 160 |
with gr.Blocks() as generate_tab:
|
| 161 |
out_audio = gr.Audio(label='Output Audio', interactive=False, streaming=False, autoplay=True)
|
| 162 |
generate_btn = gr.Button('Generate', variant='primary')
|
|
|
|
| 184 |
BANNER_TEXT = '''
|
| 185 |
[***Kokoro*** **is an open-weight TTS model with 82 million parameters.**](https://huggingface.co/hexgrad/Kokoro-82M)
|
| 186 |
|
| 187 |
+
This demo showcases Indonesian with English accent
|
| 188 |
'''
|
| 189 |
API_OPEN = os.getenv('SPACE_ID') != 'hexgrad/Kokoro-TTS'
|
| 190 |
API_NAME = None if API_OPEN else False
|