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
|
@ -76,7 +76,7 @@ void *LinuxTextToSpeechManager::startSpeech(void *p) {
|
|||
pthread_mutex_unlock(params->mutex);
|
||||
return NULL;
|
||||
}
|
||||
if(spd_say(_connection, SPD_MESSAGE, params->speechQueue->front().c_str()) == -1) {
|
||||
if (spd_say(_connection, SPD_MESSAGE, params->speechQueue->front().c_str()) == -1) {
|
||||
// close the connection
|
||||
if (_connection != 0) {
|
||||
spd_close(_connection);
|
||||
|
@ -141,7 +141,7 @@ void LinuxTextToSpeechManager::updateState(LinuxTextToSpeechManager::SpeechEvent
|
|||
case SPEECH_ENDED:
|
||||
pthread_mutex_lock(&_speechMutex);
|
||||
_speechQueue.pop_front();
|
||||
if (_speechQueue.size() == 0)
|
||||
if (_speechQueue.empty())
|
||||
_speechState = READY;
|
||||
else {
|
||||
// reinitialize if needed
|
||||
|
@ -286,7 +286,7 @@ bool LinuxTextToSpeechManager::resume() {
|
|||
_threadCreated = false;
|
||||
}
|
||||
_speechState = PAUSED;
|
||||
if (_speechQueue.size()) {
|
||||
if (!_speechQueue.empty()) {
|
||||
_speechState = SPEAKING;
|
||||
startSpeech((void *) &_params);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ void WindowsTextToSpeechManager::init() {
|
|||
|
||||
// init voice
|
||||
hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&_voice);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
if (FAILED(hr)) {
|
||||
warning("Could not initialize TTS voice");
|
||||
return;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void WindowsTextToSpeechManager::init() {
|
|||
|
||||
_voice->SetOutput(_audio, FALSE);
|
||||
|
||||
if (_ttsState->_availableVoices.size() > 0)
|
||||
if (!_ttsState->_availableVoices.empty())
|
||||
_speechState = READY;
|
||||
else
|
||||
_speechState = NO_VOICE;
|
||||
|
@ -156,7 +156,7 @@ DWORD WINAPI startSpeech(LPVOID parameters) {
|
|||
|
||||
bool WindowsTextToSpeechManager::say(Common::String str, Action action, Common::String charset) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ void WindowsTextToSpeechManager::updateVoices() {
|
|||
_voice->SetVolume(_ttsState->_volume);
|
||||
cpEnum->Release();
|
||||
|
||||
if (_ttsState->_availableVoices.size() == 0) {
|
||||
if (_ttsState->_availableVoices.empty()) {
|
||||
_speechState = NO_VOICE;
|
||||
warning("No voice is available");
|
||||
} else if (_speechState == NO_VOICE)
|
||||
|
|
|
@ -1807,7 +1807,7 @@ void GlobalOptionsDialog::build() {
|
|||
for(unsigned i = 0; i < voices.size(); i++) {
|
||||
_ttsVoiceSelectionPopUp->appendEntry(voices[i].getDescription(), i);
|
||||
}
|
||||
if (voices.size() == 0)
|
||||
if (voices.empty())
|
||||
_ttsVoiceSelectionPopUp->appendEntry("None", 0);
|
||||
|
||||
if (ConfMan.hasKey("tts_voice") && (unsigned) ConfMan.getInt("tts_voice", _domain) < voices.size())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue