TTS: Refactoring
Refactoring as suggested by bluegr on github.
This commit is contained in:
parent
07acdb8433
commit
c402666635
3 changed files with 8 additions and 8 deletions
|
@ -141,7 +141,7 @@ void LinuxTextToSpeechManager::updateState(LinuxTextToSpeechManager::SpeechEvent
|
||||||
case SPEECH_ENDED:
|
case SPEECH_ENDED:
|
||||||
pthread_mutex_lock(&_speechMutex);
|
pthread_mutex_lock(&_speechMutex);
|
||||||
_speechQueue.pop_front();
|
_speechQueue.pop_front();
|
||||||
if (_speechQueue.size() == 0)
|
if (_speechQueue.empty())
|
||||||
_speechState = READY;
|
_speechState = READY;
|
||||||
else {
|
else {
|
||||||
// reinitialize if needed
|
// reinitialize if needed
|
||||||
|
@ -286,7 +286,7 @@ bool LinuxTextToSpeechManager::resume() {
|
||||||
_threadCreated = false;
|
_threadCreated = false;
|
||||||
}
|
}
|
||||||
_speechState = PAUSED;
|
_speechState = PAUSED;
|
||||||
if (_speechQueue.size()) {
|
if (!_speechQueue.empty()) {
|
||||||
_speechState = SPEAKING;
|
_speechState = SPEAKING;
|
||||||
startSpeech((void *) &_params);
|
startSpeech((void *) &_params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ void WindowsTextToSpeechManager::init() {
|
||||||
|
|
||||||
// init voice
|
// init voice
|
||||||
hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&_voice);
|
hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&_voice);
|
||||||
if (!SUCCEEDED(hr)) {
|
if (FAILED(hr)) {
|
||||||
warning("Could not initialize TTS voice");
|
warning("Could not initialize TTS voice");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ void WindowsTextToSpeechManager::init() {
|
||||||
|
|
||||||
_voice->SetOutput(_audio, FALSE);
|
_voice->SetOutput(_audio, FALSE);
|
||||||
|
|
||||||
if (_ttsState->_availableVoices.size() > 0)
|
if (!_ttsState->_availableVoices.empty())
|
||||||
_speechState = READY;
|
_speechState = READY;
|
||||||
else
|
else
|
||||||
_speechState = NO_VOICE;
|
_speechState = NO_VOICE;
|
||||||
|
@ -156,7 +156,7 @@ DWORD WINAPI startSpeech(LPVOID parameters) {
|
||||||
|
|
||||||
bool WindowsTextToSpeechManager::say(Common::String str, Action action, Common::String charset) {
|
bool WindowsTextToSpeechManager::say(Common::String str, Action action, Common::String charset) {
|
||||||
if (_speechState == BROKEN || _speechState == NO_VOICE) {
|
if (_speechState == BROKEN || _speechState == NO_VOICE) {
|
||||||
warning("The tts cannot speak in this state");
|
warning("The text to speech cannot speak in this state");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ void WindowsTextToSpeechManager::updateVoices() {
|
||||||
_voice->SetVolume(_ttsState->_volume);
|
_voice->SetVolume(_ttsState->_volume);
|
||||||
cpEnum->Release();
|
cpEnum->Release();
|
||||||
|
|
||||||
if (_ttsState->_availableVoices.size() == 0) {
|
if (_ttsState->_availableVoices.empty()) {
|
||||||
_speechState = NO_VOICE;
|
_speechState = NO_VOICE;
|
||||||
warning("No voice is available");
|
warning("No voice is available");
|
||||||
} else if (_speechState == NO_VOICE)
|
} else if (_speechState == NO_VOICE)
|
||||||
|
|
|
@ -1807,7 +1807,7 @@ void GlobalOptionsDialog::build() {
|
||||||
for(unsigned i = 0; i < voices.size(); i++) {
|
for(unsigned i = 0; i < voices.size(); i++) {
|
||||||
_ttsVoiceSelectionPopUp->appendEntry(voices[i].getDescription(), i);
|
_ttsVoiceSelectionPopUp->appendEntry(voices[i].getDescription(), i);
|
||||||
}
|
}
|
||||||
if (voices.size() == 0)
|
if (voices.empty())
|
||||||
_ttsVoiceSelectionPopUp->appendEntry("None", 0);
|
_ttsVoiceSelectionPopUp->appendEntry("None", 0);
|
||||||
|
|
||||||
if (ConfMan.hasKey("tts_voice") && (unsigned) ConfMan.getInt("tts_voice", _domain) < voices.size())
|
if (ConfMan.hasKey("tts_voice") && (unsigned) ConfMan.getInt("tts_voice", _domain) < voices.size())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue