TTS: Refactoring
* Delete multiple empty rows * Make getVolume non-virtual and leave just the implementation in base class * Resolve warning about signed / unsigned comparison in gui-manager * Clear availableVoices when updating voices on linux * By default set language to transMan language on windows (if the transMan is available) * Remove freeVoices method from Windows ttsMan, it isn't needed anymore
This commit is contained in:
parent
4ec10ffec7
commit
58065ceacd
9 changed files with 10 additions and 26 deletions
|
@ -182,7 +182,6 @@ bool LinuxTextToSpeechManager::say(Common::String str, Common::String charset) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LinuxTextToSpeechManager::stop() {
|
bool LinuxTextToSpeechManager::stop() {
|
||||||
|
@ -248,10 +247,6 @@ void LinuxTextToSpeechManager::setVolume(unsigned volume) {
|
||||||
_ttsState->_volume = volume;
|
_ttsState->_volume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LinuxTextToSpeechManager::getVolume() {
|
|
||||||
return (_ttsState->_volume - 50) * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxTextToSpeechManager::setLanguage(Common::String language) {
|
void LinuxTextToSpeechManager::setLanguage(Common::String language) {
|
||||||
if (_speechState == BROKEN)
|
if (_speechState == BROKEN)
|
||||||
return;
|
return;
|
||||||
|
@ -278,6 +273,7 @@ void LinuxTextToSpeechManager::updateVoices() {
|
||||||
it depends on the user to map them to the right voices in speech-dispatcher
|
it depends on the user to map them to the right voices in speech-dispatcher
|
||||||
configuration
|
configuration
|
||||||
*/
|
*/
|
||||||
|
_ttsState->_availableVoices.clear();
|
||||||
|
|
||||||
char **voiceInfo = spd_list_voices(_connection);
|
char **voiceInfo = spd_list_voices(_connection);
|
||||||
|
|
||||||
|
@ -294,7 +290,6 @@ void LinuxTextToSpeechManager::updateVoices() {
|
||||||
free(voiceInfo[i]);
|
free(voiceInfo[i]);
|
||||||
|
|
||||||
free(voiceInfo);
|
free(voiceInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxTextToSpeechManager::freeVoiceData(void *data) {
|
void LinuxTextToSpeechManager::freeVoiceData(void *data) {
|
||||||
|
|
|
@ -59,7 +59,6 @@ public:
|
||||||
virtual void setPitch(int pitch);
|
virtual void setPitch(int pitch);
|
||||||
|
|
||||||
virtual void setVolume(unsigned volume);
|
virtual void setVolume(unsigned volume);
|
||||||
virtual int getVolume();
|
|
||||||
|
|
||||||
virtual void setLanguage(Common::String language);
|
virtual void setLanguage(Common::String language);
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,13 @@ void WindowsTextToSpeechManager::init() {
|
||||||
warning("Could not initialize TTS voice");
|
warning("Could not initialize TTS voice");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_TRANSLATION
|
||||||
|
setLanguage(TransMan.getCurrentLanguage());
|
||||||
|
#else
|
||||||
setLanguage("en");
|
setLanguage("en");
|
||||||
|
#endif
|
||||||
|
|
||||||
_voice->SetOutput(_audio, FALSE);
|
_voice->SetOutput(_audio, FALSE);
|
||||||
|
|
||||||
if(_ttsState->_availableVoices.size() > 0)
|
if(_ttsState->_availableVoices.size() > 0)
|
||||||
|
@ -86,7 +92,6 @@ void WindowsTextToSpeechManager::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowsTextToSpeechManager::~WindowsTextToSpeechManager() {
|
WindowsTextToSpeechManager::~WindowsTextToSpeechManager() {
|
||||||
freeVoices();
|
|
||||||
if (_voice)
|
if (_voice)
|
||||||
_voice->Release();
|
_voice->Release();
|
||||||
::CoUninitialize();
|
::CoUninitialize();
|
||||||
|
@ -207,16 +212,6 @@ void WindowsTextToSpeechManager::setVolume(unsigned volume) {
|
||||||
_ttsState->_volume = volume;
|
_ttsState->_volume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WindowsTextToSpeechManager::getVolume() {
|
|
||||||
return _ttsState->_volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowsTextToSpeechManager::freeVoices() {
|
|
||||||
_ttsState->_availableVoices.clear();
|
|
||||||
// The voice data gets freed automaticly, when the reference counting inside TTSVoice
|
|
||||||
// reaches 0, so there is no point in trying to free it here
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowsTextToSpeechManager::setLanguage(Common::String language) {
|
void WindowsTextToSpeechManager::setLanguage(Common::String language) {
|
||||||
if (language == "C")
|
if (language == "C")
|
||||||
language = "en";
|
language = "en";
|
||||||
|
@ -322,7 +317,7 @@ Common::String WindowsTextToSpeechManager::lcidToLocale(Common::String lcid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsTextToSpeechManager::updateVoices() {
|
void WindowsTextToSpeechManager::updateVoices() {
|
||||||
freeVoices();
|
_ttsState->_availableVoices.clear();
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
ISpObjectToken *cpVoiceToken = nullptr;
|
ISpObjectToken *cpVoiceToken = nullptr;
|
||||||
IEnumSpObjectTokens *cpEnum = nullptr;
|
IEnumSpObjectTokens *cpEnum = nullptr;
|
||||||
|
|
|
@ -60,7 +60,6 @@ public:
|
||||||
virtual void setPitch(int pitch);
|
virtual void setPitch(int pitch);
|
||||||
|
|
||||||
virtual void setVolume(unsigned volume);
|
virtual void setVolume(unsigned volume);
|
||||||
virtual int getVolume();
|
|
||||||
|
|
||||||
virtual void setLanguage(Common::String language);
|
virtual void setLanguage(Common::String language);
|
||||||
|
|
||||||
|
@ -70,7 +69,6 @@ private:
|
||||||
void init();
|
void init();
|
||||||
virtual void updateVoices();
|
virtual void updateVoices();
|
||||||
void createVoice(void *cpVoiceToken);
|
void createVoice(void *cpVoiceToken);
|
||||||
void freeVoices();
|
|
||||||
Common::String lcidToLocale(Common::String lcid);
|
Common::String lcidToLocale(Common::String lcid);
|
||||||
SpeechState _speechState;
|
SpeechState _speechState;
|
||||||
};
|
};
|
||||||
|
|
|
@ -228,7 +228,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the current voice volume
|
* Returns the current voice volume
|
||||||
*/
|
*/
|
||||||
virtual int getVolume() { return _ttsState->_volume; }
|
int getVolume() { return _ttsState->_volume; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the speech language
|
* Sets the speech language
|
||||||
|
|
|
@ -641,7 +641,7 @@ void GuiManager::initTextToSpeech() {
|
||||||
volume = 0;
|
volume = 0;
|
||||||
ttsMan->setVolume(volume);
|
ttsMan->setVolume(volume);
|
||||||
|
|
||||||
int voice;
|
unsigned voice;
|
||||||
if(ConfMan.hasKey("tts_voice"))
|
if(ConfMan.hasKey("tts_voice"))
|
||||||
voice = ConfMan.getInt("tts_voice", "scummvm");
|
voice = ConfMan.getInt("tts_voice", "scummvm");
|
||||||
else
|
else
|
||||||
|
|
|
@ -177,7 +177,6 @@ protected:
|
||||||
|
|
||||||
void giveFocusToDialog(Dialog *dialog);
|
void giveFocusToDialog(Dialog *dialog);
|
||||||
void setLastMousePos(int16 x, int16 y);
|
void setLastMousePos(int16 x, int16 y);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace GUI
|
} // End of namespace GUI
|
||||||
|
|
|
@ -426,7 +426,6 @@ void OptionsDialog::build() {
|
||||||
_subSpeedSlider->setValue(speed);
|
_subSpeedSlider->setValue(speed);
|
||||||
_subSpeedLabel->setValue(speed);
|
_subSpeedLabel->setValue(speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::clean() {
|
void OptionsDialog::clean() {
|
||||||
|
|
|
@ -223,7 +223,6 @@ private:
|
||||||
|
|
||||||
CheckboxWidget *_muteCheckbox;
|
CheckboxWidget *_muteCheckbox;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//
|
//
|
||||||
// Game GUI options
|
// Game GUI options
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue