aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/text-to-speech.cpp13
-rw-r--r--common/text-to-speech.h2
2 files changed, 14 insertions, 1 deletions
diff --git a/common/text-to-speech.cpp b/common/text-to-speech.cpp
index cdfc8ab77f..fa74e53c36 100644
--- a/common/text-to-speech.cpp
+++ b/common/text-to-speech.cpp
@@ -145,5 +145,18 @@ Array<int> TextToSpeechManager::getVoiceIndicesByGender(TTSVoice::Gender gender)
return results;
}
+void TextToSpeechManager::setLanguage(Common::String language) {
+ if (language == "C")
+ language = "en";
+ // The speech manager uses the ISO 639-1 for language codes (2 letter code)
+ // if we get a longer language string, just take the first 2 letters from that
+ // if it won't be a valid language code, the Manager just won't find any voice
+ // for it. This way a code like (en_GB) can also be passed to this.
+ if (language.size() > 2) {
+ language.erase(2, Common::String::npos);
+ }
+ _ttsState->_language = language;
+}
+
}
#endif
diff --git a/common/text-to-speech.h b/common/text-to-speech.h
index 8e86721701..14cbab17a5 100644
--- a/common/text-to-speech.h
+++ b/common/text-to-speech.h
@@ -271,7 +271,7 @@ public:
* because voices are usually language specific and so it is set to some platform
* specific default after switching languages.
*/
- virtual void setLanguage(String language) { _ttsState->_language = language; }
+ virtual void setLanguage(String language);
/**
* Returns the current speech language