diff options
-rw-r--r-- | src/mumble/Settings.cpp | 3 | ||||
-rw-r--r-- | src/mumble/Settings.h | 9 | ||||
-rw-r--r-- | src/mumble/TextToSpeech_unix.cpp | 16 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/mumble/Settings.cpp b/src/mumble/Settings.cpp index 29da40b52..c3f8b5f66 100644 --- a/src/mumble/Settings.cpp +++ b/src/mumble/Settings.cpp @@ -252,6 +252,7 @@ Settings::Settings() { bTTSMessageReadBack = false; iTTSVolume = 75; iTTSThreshold = 250; + qsTTSLanguage = QString(); iQuality = 40000; fVolume = 1.0f; fOtherVolume = 0.5f; @@ -647,6 +648,7 @@ void Settings::load(QSettings* settings_ptr) { SAVELOAD(iTTSVolume, "tts/volume"); SAVELOAD(iTTSThreshold, "tts/threshold"); SAVELOAD(bTTSMessageReadBack, "tts/readback"); + SAVELOAD(qsTTSLanguage, "tts/language"); // Network settings SAVELOAD(bTCPCompat, "net/tcponly"); @@ -956,6 +958,7 @@ void Settings::save() { SAVELOAD(iTTSVolume, "tts/volume"); SAVELOAD(iTTSThreshold, "tts/threshold"); SAVELOAD(bTTSMessageReadBack, "tts/readback"); + SAVELOAD(qsTTSLanguage, "tts/language"); // Network settings SAVELOAD(bTCPCompat, "net/tcponly"); diff --git a/src/mumble/Settings.h b/src/mumble/Settings.h index 62d092fca..7c86d8935 100644 --- a/src/mumble/Settings.h +++ b/src/mumble/Settings.h @@ -188,6 +188,15 @@ struct Settings { bool bWhisperFriends; bool bTTSMessageReadBack; int iTTSVolume, iTTSThreshold; + /// The Text-to-Speech language to use. This setting overrides + /// the default language for the Text-to-Speech engine, which + /// is usually inferred from the current locale. + /// + /// The language is expected to be in BCP47 form. + /// + /// The setting is currently only supported by the speech-dispatcher + ///backend. + QString qsTTSLanguage; int iQuality, iMinLoudness, iVoiceHold, iJitterBufferSize; int iNoiseSuppress; 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) |