aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-10-16 18:42:16 +0200
committerJaromir Wysoglad2019-10-16 19:30:56 +0200
commitb9d3c84db4e10cc0e55e4c2a12e288c17c7e66d2 (patch)
treea2c4d3931b78579b04a737094d29e2b6cf21a278 /common
parent94d17b1853a77db0bf34cb6192d88a58d0766130 (diff)
downloadscummvm-rg350-b9d3c84db4e10cc0e55e4c2a12e288c17c7e66d2.tar.gz
scummvm-rg350-b9d3c84db4e10cc0e55e4c2a12e288c17c7e66d2.tar.bz2
scummvm-rg350-b9d3c84db4e10cc0e55e4c2a12e288c17c7e66d2.zip
TTS: Fix language setting.
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