Spaces:
Runtime error
Runtime error
Lojban support
Browse files
app.py
CHANGED
|
@@ -59,7 +59,11 @@ def text_to_ipa(text, lang='en-us'):
|
|
| 59 |
ipa_sections = re.findall(regex, text)
|
| 60 |
text = re.sub(regex, '[]', text)
|
| 61 |
|
| 62 |
-
if lang
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
local_phonemizer = phonemizer.backend.EspeakBackend(language=lang, preserve_punctuation=True, with_stress=True)
|
| 64 |
ps = local_phonemizer.phonemize([text])
|
| 65 |
ps = ps[0]
|
|
@@ -202,7 +206,7 @@ for v in CHOICES.values():
|
|
| 202 |
TOKEN_NOTE = '''
|
| 203 |
💡 Customize pronunciation with Markdown link syntax and /slashes/ like `[Kokoro](/kˈOkəɹO/)`
|
| 204 |
|
| 205 |
-
💬 To adjust intonation, try punctuation `;:,.!?—…"()
|
| 206 |
|
| 207 |
⬇️ Lower stress `[1 level](-1)` or `[2 levels](-2)`
|
| 208 |
|
|
@@ -236,7 +240,7 @@ with gr.Blocks() as stream_tab:
|
|
| 236 |
BANNER_TEXT = '''
|
| 237 |
[***Kokoro*** **is an open-weight TTS model with 82 million parameters.**](https://huggingface.co/hexgrad/Kokoro-82M)
|
| 238 |
|
| 239 |
-
This demo supports multiple languages using G2P and phonemizer. Select your language below!
|
| 240 |
'''
|
| 241 |
|
| 242 |
API_OPEN = os.getenv('SPACE_ID') != 'hexgrad/Kokoro-TTS'
|
|
@@ -245,23 +249,24 @@ API_NAME = None if API_OPEN else False
|
|
| 245 |
# Language choices for the dropdown
|
| 246 |
LANGUAGE_CHOICES = [
|
| 247 |
['English (US)', 'en-us'],
|
| 248 |
-
['Czech (Non-native)', 'cs'],
|
| 249 |
-
['Danish (Non-native)', 'da'],
|
| 250 |
-
['Dutch (Non-native)', 'nl'],
|
| 251 |
-
['Estonian (Non-native)', 'et'],
|
| 252 |
-
['Finnish (Non-native)', 'fi'],
|
| 253 |
-
['French (Non-native)', 'fr'],
|
| 254 |
-
['German (Non-native)', 'de'],
|
| 255 |
-
['Greek (Non-native)', 'el'],
|
| 256 |
-
['Italian (Non-native)', 'it'],
|
| 257 |
-
['Norwegian (Non-native)', 'no'],
|
| 258 |
-
['Polish (Non-native)', 'pl'],
|
| 259 |
-
['Portuguese (Non-native)', 'pt'],
|
| 260 |
-
['Russian (Non-native)', 'ru'],
|
| 261 |
-
['Slovene (Non-native)', 'sl'],
|
| 262 |
-
['Spanish (Non-native)', 'es'],
|
| 263 |
-
['Swedish (Non-native)', 'sv'],
|
| 264 |
-
['Turkish (Non-native)', 'tr'],
|
|
|
|
| 265 |
]
|
| 266 |
|
| 267 |
with gr.Blocks() as app:
|
|
|
|
| 59 |
ipa_sections = re.findall(regex, text)
|
| 60 |
text = re.sub(regex, '[]', text)
|
| 61 |
|
| 62 |
+
if lang == 'jb':
|
| 63 |
+
# Lojban language
|
| 64 |
+
import lojban
|
| 65 |
+
ps = lojban.lojban2ipa(text, 'vits')
|
| 66 |
+
elif lang in LANG_NAMES:
|
| 67 |
local_phonemizer = phonemizer.backend.EspeakBackend(language=lang, preserve_punctuation=True, with_stress=True)
|
| 68 |
ps = local_phonemizer.phonemize([text])
|
| 69 |
ps = ps[0]
|
|
|
|
| 206 |
TOKEN_NOTE = '''
|
| 207 |
💡 Customize pronunciation with Markdown link syntax and /slashes/ like `[Kokoro](/kˈOkəɹO/)`
|
| 208 |
|
| 209 |
+
💬 To adjust intonation, try punctuation `;:,.!?—…"()“”` or stress `ˈ` and `ˌ`
|
| 210 |
|
| 211 |
⬇️ Lower stress `[1 level](-1)` or `[2 levels](-2)`
|
| 212 |
|
|
|
|
| 240 |
BANNER_TEXT = '''
|
| 241 |
[***Kokoro*** **is an open-weight TTS model with 82 million parameters.**](https://huggingface.co/hexgrad/Kokoro-82M)
|
| 242 |
|
| 243 |
+
This demo uses native US English and British English speakers. But also supports multiple languages using G2P and phonemizer. Select your language below!
|
| 244 |
'''
|
| 245 |
|
| 246 |
API_OPEN = os.getenv('SPACE_ID') != 'hexgrad/Kokoro-TTS'
|
|
|
|
| 249 |
# Language choices for the dropdown
|
| 250 |
LANGUAGE_CHOICES = [
|
| 251 |
['English (US)', 'en-us'],
|
| 252 |
+
# ['Czech (Non-native)', 'cs'],
|
| 253 |
+
# ['Danish (Non-native)', 'da'],
|
| 254 |
+
# ['Dutch (Non-native)', 'nl'],
|
| 255 |
+
# ['Estonian (Non-native)', 'et'],
|
| 256 |
+
# ['Finnish (Non-native)', 'fi'],
|
| 257 |
+
# ['French (Non-native)', 'fr'],
|
| 258 |
+
# ['German (Non-native)', 'de'],
|
| 259 |
+
# ['Greek (Non-native)', 'el'],
|
| 260 |
+
# ['Italian (Non-native)', 'it'],
|
| 261 |
+
# ['Norwegian (Non-native)', 'no'],
|
| 262 |
+
# ['Polish (Non-native)', 'pl'],
|
| 263 |
+
# ['Portuguese (Non-native)', 'pt'],
|
| 264 |
+
# ['Russian (Non-native)', 'ru'],
|
| 265 |
+
# ['Slovene (Non-native)', 'sl'],
|
| 266 |
+
# ['Spanish (Non-native)', 'es'],
|
| 267 |
+
# ['Swedish (Non-native)', 'sv'],
|
| 268 |
+
# ['Turkish (Non-native)', 'tr'],
|
| 269 |
+
['Lojban', 'jb'],
|
| 270 |
]
|
| 271 |
|
| 272 |
with gr.Blocks() as app:
|