aboutsummaryrefslogtreecommitdiff
path: root/backends/text-to-speech/linux/linux-text-to-speech.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/text-to-speech/linux/linux-text-to-speech.cpp')
-rw-r--r--backends/text-to-speech/linux/linux-text-to-speech.cpp44
1 files changed, 15 insertions, 29 deletions
diff --git a/backends/text-to-speech/linux/linux-text-to-speech.cpp b/backends/text-to-speech/linux/linux-text-to-speech.cpp
index 47c441a361..49aefdb8b4 100644
--- a/backends/text-to-speech/linux/linux-text-to-speech.cpp
+++ b/backends/text-to-speech/linux/linux-text-to-speech.cpp
@@ -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));
-
- type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
- *type = SPD_MALE2;
- _ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::MALE, (void *) type));
-
- 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));
+ char **voiceInfo = spd_list_voices(_connection);
- type = (SPDVoiceType *) malloc(sizeof(SPDVoiceType));
- *type = SPD_CHILD_MALE;
- _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_CHILD_FEMALE;
- _ttsState->_availaibleVoices.push_back(Common::TTSVoice(Common::TTSVoice::FEMALE, (void *) type));
}
#endif