TTS: Add voice selection to options

This commit is contained in:
Jaromir Wysoglad 2019-07-12 22:16:44 +02:00 committed by Filippos Karapetis
parent b5cebcbeae
commit 8bd7e39265
8 changed files with 61 additions and 32 deletions

View file

@ -180,6 +180,12 @@ void LinuxTextToSpeechManager::setLanguage(Common::String language) {
setVoice(_ttsState->_activeVoice);
}
void LinuxTextToSpeechManager::createVoice(int typeNumber, Common::TTSVoice::Gender gender, char *description) {
SPDVoiceType *type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = static_cast<SPDVoiceType>(typeNumber);
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(gender, (void *) type, description));
}
void LinuxTextToSpeechManager::updateVoices() {
if (_speechState == BROKEN)
return;
@ -192,37 +198,17 @@ void LinuxTextToSpeechManager::updateVoices() {
configuration
*/
SPDVoiceType *type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = SPD_MALE1;
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::MALE, (void *) type));
char **voiceInfo = spd_list_voices(_connection);
type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = SPD_MALE2;
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::MALE, (void *) type));
createVoice(SPD_MALE1, Common::TTSVoice::MALE, voiceInfo[0]);
createVoice(SPD_MALE2, Common::TTSVoice::MALE, voiceInfo[1]);
createVoice(SPD_MALE3, Common::TTSVoice::MALE, voiceInfo[2]);
createVoice(SPD_FEMALE1, Common::TTSVoice::FEMALE, voiceInfo[3]);
createVoice(SPD_FEMALE2, Common::TTSVoice::FEMALE, voiceInfo[4]);
createVoice(SPD_FEMALE3, Common::TTSVoice::FEMALE, voiceInfo[5]);
createVoice(SPD_CHILD_MALE, Common::TTSVoice::MALE, voiceInfo[6]);
createVoice(SPD_CHILD_FEMALE, Common::TTSVoice::FEMALE, voiceInfo[7]);
type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = SPD_MALE3;
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::MALE, (void *) type));
type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = SPD_FEMALE1;
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::FEMALE, (void *) type));
type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = SPD_FEMALE2;
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::FEMALE, (void *) type));
type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = SPD_FEMALE3;
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::FEMALE, (void *) type));
type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = SPD_CHILD_MALE;
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::MALE, (void *) type));
type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
*type = SPD_CHILD_FEMALE;
_ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::FEMALE, (void *) type));
}
#endif