Talkey无法切换eSpeak语音求助:葡萄牙语女声配置无效
Let me walk you through fixing this—I’ve run into similar Talkey configuration hiccups before!
First, let’s break down the potential issues and solutions step by step:
1. Verify MBROLA Voice Files Are Installed
The brazil-mbrola-4 voice depends on the MBROLA engine and its corresponding voice package, which most systems don’t install by default. Let’s rule this out first:
- Test if eSpeak can use the voice directly from the command line:
espeak -v brazil-mbrola-4 "Olá, esta é uma voz feminina de teste" - If you get an error like
Cannot find voice 'brazil-mbrola-4'or no sound, install the required packages:- For Debian/Ubuntu-based systems:
sudo apt-get install mbrola mbrola-br4 - For other systems, download the
mb-br4voice file from the MBROLA repository and place it in/usr/share/mbrola/(or~/.mbrola/for user-specific installs).
- For Debian/Ubuntu-based systems:
2. Fix Talkey’s Language Code Mapping
Talkey expects language keys that match eSpeak’s precise language codes. Your original config uses pt (generic Portuguese), but the brazil-mbrola-4 voice is tied to pt-br (Brazilian Portuguese). Let’s adjust that:
tts = talkey.Talkey( preferred_languages=['pt-br'], # Use precise regional code engine_preference=['espeak'], espeak={ 'options':{ 'enabled': True, }, 'languages':{ 'pt-br': { # Match the preferred language code 'voice': 'brazil-mbrola-4' }, } } )
3. Add Extra Arguments to Force Voice Selection
If the above still doesn’t work, Talkey’s internal voice mapping might be misfiring. Add direct eSpeak arguments to enforce the voice:
tts = talkey.Talkey( preferred_languages=['pt-br'], engine_preference=['espeak'], espeak={ 'options':{ 'enabled': True, }, 'languages':{ 'pt-br': { 'voice': 'brazil-mbrola-4', 'extra_args': ['-v', 'brazil-mbrola-4'] # Force eSpeak to use this voice }, } } )
Final Check
After installing the MBROLA packages and adjusting the config, test with a simple line to confirm:
tts.say("Olá! Agora a voz deve ser feminina brasileira.")
内容的提问来源于stack exchange,提问作者Giovana Morais

