-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use pyttsx to play the Chinese? #50
Comments
I have no idea. I've just taken over this project, and honestly, haven't had much time to familiarize myself with the code yet. |
Perhaps this is pertinent? https://stackoverflow.com/questions/18715563/how-to-tts-chinese-using-pyttsx |
voices = ['com.apple.speech.synthesis.voice.mei-jia', It‘s OK. |
I want to play chances in ubuntu, I found it actually always said "chinese letter letter letter ..." and so on.
The script is
|
I run pyttsx3 in Ubuntu 20.04.4 LTS,the voices[ ].id is Mandarin. But after I trace the code, I find even I set the setProperty as Mandarin, pyttsx3 still use "default" to be get in getProperty. So try to modify the /usr/lib/aarch64-linux-gnu/espeak-data/voices/default as below. name default And modify the python code "engine.setProperty('voice', voices[-2].id)" to "engine.setProperty('voice', 'zh')", then it works!
|
I have created a small function help find a voice in Chinese: import pyttsx3
from pyttsx3.voice import Voice
def get_chinese_voice(engine: pyttsx3.engine.Engine) -> Voice:
voices = engine.getProperty("voices")
for voice in voices:
if voice.languages and voice.languages[0] == "zh-CN":
return voice
if "Chinese" in voice.name or "Mandarin" in voice.name.title():
return voice
raise RuntimeError(f"No Chinese voice found among {voices}") You can use as such: tts_engine = pyttsx3.init()
chinese_voice = get_chinese_voice(tts_engine)
tts_engine.setProperty("voice", chinese_voice.id) |
Can pyttsx play Chinese? If so, what should do that? Do I need to install the Chinese library? If so, how do I download and install?
The text was updated successfully, but these errors were encountered: