diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2016-01-31 14:13:23 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2016-01-31 14:14:14 +0300 |
commit | 1aae05eba12b06f8aa3604bae84738edb4fbb892 (patch) | |
tree | af41fdb57cfaceecf3954c4df637beb99288b01a /src/mumble/TextToSpeech_unix.cpp | |
parent | bd8f92b983f3950500f92ba85051542fa9478474 (diff) |
TextToSpeech_unix: use Mumble's language setting, or the system locale for TTS language.
This commit adds code to TextToSpeech_unix to set
the desired TextToSpeech language that speech-dispatcher
should use.
In addition, this commit also adds a new setting,
"tts/language". This is a BCP 47-style language code
that TTS engines will attemp to adhere to.
I put it in, to allow users to still be able to use
an English TTS engine, while using Mumble in another
language.
For now, "tts/language" is a hidden setting -- it has
no UI to configure it.
Fixes mumble-voip/mumble#2066
Diffstat (limited to 'src/mumble/TextToSpeech_unix.cpp')
-rw-r--r-- | src/mumble/TextToSpeech_unix.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mumble/TextToSpeech_unix.cpp b/src/mumble/TextToSpeech_unix.cpp index 6443c0702..00a37737d 100644 --- a/src/mumble/TextToSpeech_unix.cpp +++ b/src/mumble/TextToSpeech_unix.cpp @@ -60,6 +60,22 @@ TextToSpeechPrivate::TextToSpeechPrivate() { if (! spd) { qWarning("TextToSpeech: Failed to contact speech dispatcher."); } else { + QString lang; + if (!g.s.qsTTSLanguage.isEmpty()) { + lang = g.s.qsTTSLanguage; + } else if (!g.s.qsLanguage.isEmpty()) { + QLocale locale(g.s.qsLanguage); + lang = locale.bcp47Name(); + } else { + QLocale systemLocale; + lang = systemLocale.bcp47Name(); + } + if (!lang.isEmpty()) { + if (spd_set_language(spd, lang.toLocal8Bit().constData()) != 0) { + qWarning("TextToSpeech: Failed to set language."); + } + } + if (spd_set_punctuation(spd, SPD_PUNCT_NONE) != 0) qWarning("TextToSpech: Failed to set punctuation mode."); if (spd_set_spelling(spd, SPD_SPELL_ON) != 0) |