From 1aae05eba12b06f8aa3604bae84738edb4fbb892 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Sun, 31 Jan 2016 12:13:23 +0100 Subject: 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 --- src/mumble/TextToSpeech_unix.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/mumble/TextToSpeech_unix.cpp') 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) -- cgit v1.2.3