[dasher: 106/217] Linux Speak will use voice with language of current alphabet.



commit ec4ec4083e50150ecb77bdbe2e125f06fc3ecbd4
Author: David Barnett <dbarnett google com>
Date:   Tue Nov 3 22:47:32 2015 -0800

    Linux Speak will use voice with language of current alphabet.

 Src/Gtk2/DasherControl.cpp    |    3 ++-
 Src/Gtk2/Speech.h             |    2 +-
 Src/Gtk2/SpeechDispatcher.cpp |    8 +++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index 4d68013..ba01d3d 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -180,7 +180,8 @@ bool CDasherControl::SupportsSpeech() {
 }
 
 void CDasherControl::Speak(const std::string &strText, bool bInterrupt) {
-  m_Speech.Speak(strText, bInterrupt);
+  string lang = GetActiveAlphabet()->GetLanguageCode();
+  m_Speech.Speak(strText, bInterrupt, lang);
 }
 #endif
 
diff --git a/Src/Gtk2/Speech.h b/Src/Gtk2/Speech.h
index dc8d3ea..b74673d 100644
--- a/Src/Gtk2/Speech.h
+++ b/Src/Gtk2/Speech.h
@@ -15,7 +15,7 @@ public:
   CSpeech();
   ~CSpeech();
   bool Init();
-  void Speak(const std::string &strText, bool bInterrupt);
+  void Speak(const std::string &strText, bool bInterrupt, const std::string &lang);
 private:
 #ifdef HAVE_SPEECHD
   SPDConnection *m_speaker;
diff --git a/Src/Gtk2/SpeechDispatcher.cpp b/Src/Gtk2/SpeechDispatcher.cpp
index 7be1e83..db604b9 100644
--- a/Src/Gtk2/SpeechDispatcher.cpp
+++ b/Src/Gtk2/SpeechDispatcher.cpp
@@ -21,11 +21,17 @@ bool CSpeech::Init() {
        return m_speaker != NULL;
 }
 
-void CSpeech::Speak(const std::string &strText, bool bInterrupt) {
+void CSpeech::Speak(const std::string &strText, bool bInterrupt, const std::string &lang) {
        if (!Init()) {
                return;
        }
        if (!bInterrupt) {
+               if (!lang.empty()) {
+                       // Speechd only accepts 2-letter language codes and
+                       // silently ignores anything else.
+                       std::string shortLang = lang.substr(0, 2);
+                       spd_set_language(m_speaker, shortLang.c_str());
+               }
                if (!strText.empty()) {
                        spd_say(m_speaker, SPD_TEXT, strText.c_str());
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]