aboutsummaryrefslogtreecommitdiff
path: root/backends/text-to-speech
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-07-12 22:16:44 +0200
committerFilippos Karapetis2019-09-01 22:47:55 +0300
commit8bd7e392657989dd49da592d8b0bf6e14fe50166 (patch)
tree83eaaabe11167533a7625fad3eaa76f7acdf01d0 /backends/text-to-speech
parentb5cebcbeaed5b1b860f2686379fc288c137a4c2f (diff)
downloadscummvm-rg350-8bd7e392657989dd49da592d8b0bf6e14fe50166.tar.gz
scummvm-rg350-8bd7e392657989dd49da592d8b0bf6e14fe50166.tar.bz2
scummvm-rg350-8bd7e392657989dd49da592d8b0bf6e14fe50166.zip
TTS: Add voice selection to options
Diffstat (limited to 'backends/text-to-speech')
-rw-r--r--backends/text-to-speech/linux/linux-text-to-speech.cpp44
-rw-r--r--backends/text-to-speech/linux/linux-text-to-speech.h1
2 files changed, 16 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
diff --git a/backends/text-to-speech/linux/linux-text-to-speech.h b/backends/text-to-speech/linux/linux-text-to-speech.h
index faa6a9d468..41c4a64d28 100644
--- a/backends/text-to-speech/linux/linux-text-to-speech.h
+++ b/backends/text-to-speech/linux/linux-text-to-speech.h
@@ -67,6 +67,7 @@ public:
private:
virtual void updateVoices();
+ void createVoice(int typeNumber, Common::TTSVoice::Gender, char *description);
SpeechState _speechState;
};