OSDN Git Service

ti34542 fix JTalk issue with non-Japanese language environment
authorTakuya Nishimoto <nishimotz@gmail.com>
Mon, 27 Oct 2014 06:25:30 +0000 (15:25 +0900)
committerTakuya Nishimoto <nishimotz@gmail.com>
Mon, 27 Oct 2014 06:25:30 +0000 (15:25 +0900)
source/synthDrivers/nvdajp_jtalk.py

index 1a455ac..25a5f6b 100644 (file)
@@ -16,6 +16,7 @@ import synthDriverHandler
 import languageHandler\r
 from jtalk import jtalkDriver\r
 from jtalk.jtalkDriver import VoiceProperty\r
+from jtalk._nvdajp_espeak import isJapaneseLang\r
 \r
 class SynthDriver(SynthDriver):\r
        """A Japanese synth driver for NVDAjp.\r
@@ -57,7 +58,15 @@ class SynthDriver(SynthDriver):
                                p.pitch = self._pitch\r
                                p.inflection = self._inflection\r
                                p.characterMode = spellState\r
-                               jtalkDriver.speak(unicode(item), currentLang, index=finalIndex, voiceProperty_=p)\r
+                               msg = unicode(item)\r
+                               isMsgJp = isJapaneseLang(msg)\r
+                               lang = currentLang\r
+                               if isMsgJp:\r
+                                       lang = 'ja'\r
+                               elif defaultLanguage != 'ja' and not isMsgJp:\r
+                                       lang = defaultLanguage\r
+                               log.debug("lang:%s idx:%s pit:%d inf:%d chr:%d (%s)" % (lang, str(finalIndex), p.pitch, p.inflection, p.characterMode, msg))\r
+                               jtalkDriver.speak(msg, lang, index=finalIndex, voiceProperty_=p)\r
                        elif isinstance(item,speech.IndexCommand):\r
                                finalIndex = item.index\r
                        elif isinstance(item,speech.CharacterModeCommand):\r