aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--common/text-to-speech.h10
-rw-r--r--gui/gui-manager.cpp15
-rw-r--r--gui/gui-manager.h2
-rw-r--r--gui/options.cpp17
-rw-r--r--gui/options.h1
-rw-r--r--gui/themes/default.inc3
8 files changed, 61 insertions, 32 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;
};
diff --git a/common/text-to-speech.h b/common/text-to-speech.h
index 8d0021e6a8..4e66cf23e4 100644
--- a/common/text-to-speech.h
+++ b/common/text-to-speech.h
@@ -44,18 +44,22 @@ class TTSVoice {
public:
TTSVoice()
: _gender(UNKNOWN)
- , _data(nullptr) {}
- TTSVoice(Gender gender, void *data)
+ , _data(nullptr)
+ , _description("") {}
+ TTSVoice(Gender gender, void *data, String description)
: _gender(gender)
- , _data(data) {}
+ , _data(data)
+ , _description(description) {}
Gender getGender() { return _gender; };
void setGender(Gender gender) { _gender = gender; };
void setData(void *data) { _data = data; };
void *getData() { return _data; };
+ String getDescription() { return _description; };
protected:
Gender _gender;
void *_data;
+ String _description;
};
struct TTSState {
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index cff8e8c5cd..89d7d45b81 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -74,6 +74,10 @@ GuiManager::GuiManager() : _redrawStatus(kRedrawDisabled), _stateIsSaved(false),
TransMan.setLanguage(ConfMan.get("gui_language").c_str());
#endif // USE_TRANSLATION
+#ifdef USE_TTS
+ initTextToSpeech();
+#endif // USE_TTS
+
ConfMan.registerDefault("gui_theme", "scummremastered");
Common::String themefile(ConfMan.get("gui_theme"));
@@ -619,4 +623,15 @@ void GuiManager::setLastMousePos(int16 x, int16 y) {
_lastMousePosition.time = _system->getMillis(true);
}
+#ifdef USE_TTS
+void GuiManager::initTextToSpeech() {
+ int voice;
+ if(ConfMan.hasKey("tts_voice"))
+ voice = ConfMan.getInt("tts_voice", "scummvm");
+ else
+ voice = 0;
+ g_system->getTextToSpeechManager()->setVoice(voice);
+}
+#endif
+
} // End of namespace GUI
diff --git a/gui/gui-manager.h b/gui/gui-manager.h
index 07ea474628..fa5e715bcb 100644
--- a/gui/gui-manager.h
+++ b/gui/gui-manager.h
@@ -176,6 +176,8 @@ protected:
void giveFocusToDialog(Dialog *dialog);
void setLastMousePos(int16 x, int16 y);
+
+ void initTextToSpeech();
};
} // End of namespace GUI
diff --git a/gui/options.cpp b/gui/options.cpp
index 1d4f6c7e99..b871e92d11 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -39,6 +39,7 @@
#include "common/translation.h"
#include "common/updates.h"
#include "common/util.h"
+#include "common/text-to-speech.h"
#include "audio/mididrv.h"
#include "audio/musicplugin.h"
@@ -1527,6 +1528,7 @@ GlobalOptionsDialog::GlobalOptionsDialog(LauncherDialog *launcher)
#ifdef USE_TTS
_enableTTS = false;
_ttsCheckbox = 0;
+ _ttsVoiceSelectionPopUp = 0;
#endif
}
@@ -1797,6 +1799,18 @@ void GlobalOptionsDialog::build() {
else
_ttsCheckbox->setState(false);
+ _ttsVoiceSelectionPopUp = new PopUpWidget(tab, "GlobalOptions_Accessibility.TTSVoiceSelection");
+ Common::Array<Common::TTSVoice> voices = g_system->getTextToSpeechManager()->getVoicesArray();
+
+ for(unsigned i = 0; i < voices.size(); i++) {
+ _ttsVoiceSelectionPopUp->appendEntry(voices[i].getDescription(), i);
+ }
+
+ if (ConfMan.hasKey("tts_voice"))
+ _ttsVoiceSelectionPopUp->setSelectedTag(ConfMan.getInt("tts_voice", _domain)) ;
+ else
+ _ttsVoiceSelectionPopUp->setSelectedTag(0);
+
#endif // USE_TTS
// Activate the first tab
@@ -2136,6 +2150,9 @@ void GlobalOptionsDialog::apply() {
}
#ifdef USE_TTS
ConfMan.setBool("tts_enabled", _ttsCheckbox->getState(), _domain);
+ int selectedVoice = _ttsVoiceSelectionPopUp->getSelectedTag();
+ ConfMan.setInt("tts_voice", selectedVoice, _domain);
+ g_system->getTextToSpeechManager()->setVoice(selectedVoice);
#endif
if (isRebuildNeeded) {
diff --git a/gui/options.h b/gui/options.h
index 5f7a6b362f..76ad4ef082 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -361,6 +361,7 @@ protected:
#ifdef USE_TTS
bool _enableTTS;
CheckboxWidget *_ttsCheckbox;
+ PopUpWidget *_ttsVoiceSelectionPopUp;
#endif
};
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index 603567d700..2982bf22ce 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -1558,6 +1558,9 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"<widget name='TTSCheckbox' "
"type='Checkbox' "
"/>"
+"<widget name='TTSVoiceSelection' "
+"type='PopUp' "
+"/>"
"</layout>"
"</dialog>"
"<dialog name='GlobalMenu' overlays='screen_center'>"