Support extra languages in multi-lang kokoro tts#2303
Conversation
|
Hi @csukuangfj, Thanks for the great work. It would be helpful if we could load the multilingual model without specifying language and provide a lang parameter at inference to the Generate function. This would enable switching language without reloading the model. I don't know if this is possible with other languages, but with dart it isn't. |
|
@csukuangfj The pull request you linked is the one we commenting on right now and I have already checked it. My request was to be able to do this in dart: final kokoro = sherpa_onnx.OfflineTtsKokoroModelConfig(
model: model,
voices: voices,
tokens: tokens,
dataDir: dataDir,
lengthScale: 1 / speed,
dictDir: dictDir,
// Initialize without lexicon or lang
);
// Create config...
final tts = sherpa_onnx.OfflineTts(config);
// Then generate in english
final audio = tts.generate(text: text, sid: sid, speed: speed, lang="en-us");
// Later generate in French
final audio = tts.generate(text: text, sid: sid, speed: speed, lang="fr");
// Later generate in Chinese
final audio = tts.generate(text: text, sid: sid, speed: speed, lang="zh");Currently whenever I want to switch from english to french, I need to reinitialized Kokoro right? |
Yes, you are right. The design of the TTS class supports many different models but not all models are multi-lingual. The interface you proposed is great, but it is difficult to change the code to support it. How about embedding the language info inside the text, e.g., if the text is
If you don't specify anything with |
|
That can work without changing the API. I suppose it will require a lot of work to change the api to provide language to the generate method even if we are still required to provide language at initialization? Something else we can do is to just pass the voice(sid) to the generate method, and check language of the voice on c/c++ side. This will work for models like kokoro because the voices are language-specific. |
A voice can speak different languages. For instance, someone may want synthesize Chinese in a British accent. |
|
The Off topic, but still wanted to ask: I saw that you have started integrating Nvidia's Canary STT model. When will the dart api for it be available? I would like to use the Thanks again for all the hard work. |
Already supported. Pleast check the latest version. |
Yes, you are right. We can select a different string other than |
Waou, thanks for the quick action.
A common pattern in multilingual gen AI is Also, if the text to be synthesized content html or xml tags e.g: "The html element to add a new line is <br>" or "<fr> is the xml tag used to configure...". That's why I prefer What do you think? |
|
@csukuangfj I noticed that the Kokoro-82M model on Hugging Face includes Japanese voices. Thank you very much for your time and support! -- |
The C++ frontend for converting Japanese text into token IDs is the main issue. |
The voice means accent. You can let a Japanese person speak English, Chinese, or whatever, with a Japanese accent. |
Thanks for the clarification! I see, so those “Japanese voices” refer to accent styles rather than actual Japanese language support. May I ask if Kokoro currently supports generating TTS in Japanese (native Japanese text input)? Thanks again for your help and for taking the time to explain this! |
Please see https://github.com/hexgrad/kokoro
Sorry, not in the near future. |
|
flutter app crashes when generating with kokoro, multi language, why? any fixes? model.dart |
what is |
|
kokoro crash when chinese D:\a\sherpa-onnx\sherpa-onnx\sherpa-onnx\csrc\kokoro-multi-lang-lexicon.cc:InitLexicon:490 Duplicated word: kokoro at line 1:kokoro k ˈ O k ə ɹ O. Ignore it. D:\a\sherpa-onnx\sherpa-onnx\sherpa-onnx/csrc/offline-tts-kokoro-impl.h:Generate:217 After normalizing: 谷歌的这项免费服务可以即时在英语和 100 多种其他语言之间翻译单词、短语和网页。 D:\a\sherpa-onnx\sherpa-onnx\sherpa-onnx\csrc\kokoro-multi-lang-lexicon.cc:ConvertTextToTokenIds:127 Non-Chinese: |
|
try to generate audio using kokoro v1.0 text to generate dont know why, engine crashes immediately all the time |
|
With this PR, kokoro-multi-lang-v1_0.tar.bz2 can support multiple languages now.
Example 1: French
30.mov
Example 2: American English
(Refer to https://k2-fsa.github.io/sherpa/onnx/tts/all/Chinese-English/kokoro-multi-lang-v1_0.html for speaker IDs corresponding to American accents)
0.mov
Example 3: British English
(Refer to https://k2-fsa.github.io/sherpa/onnx/tts/all/Chinese-English/kokoro-multi-lang-v1_0.html for speaker IDs corresponding to British accents)
22.mov
Example 4: Spanish
28.mov
Example 5: Chinese + English
48.mov
Example 6: Chinese + English
2.mov
(You can combine Chinese with French, or Chinese with Spanish, or Chinese with Italian, or Chinese with Hindi, etc.)
Example 7: Italian
35.mov
Example 8: Hindi
32.mov