<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
img {
max-width: 100%;
height: auto;
}
p.details {
font-style:italic;
color:#777
}
.footer p {
font-size:small;
color:#777
}
pre.commit-message {
white-space: pre-wrap;
}
.file-stats a {
text-decoration: none;
}
.file-stats .new-file {
color: #090;
}
.file-stats .deleted-file {
color: #B00;
}
</style>
<body>
<div class='content'>
<h3>Nalin x GNU pushed to branch master at <a href="https://gitlab.com/smc/ibus-braille">SMC / ibus-braille</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/smc/ibus-braille/commit/a95477de02724de4e174a077850fa44b5d8849e0">a95477de</a></strong>
<div>
<span>by Nalin.x.GNU</span>
<i>at 2015-09-22T06:55:00Z</i>
</div>
<pre class='commit-message'>select tts api according to availability</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
engine/engine.py
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/smc/ibus-braille/commit/a95477de02724de4e174a077850fa44b5d8849e0#diff-0'>
<strong>
engine/engine.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/engine/engine.py
</span><span style="color: #000000;background-color: #ddffdd">+++ b/engine/engine.py
</span><span style="color: #999999">@@ -25,7 +25,6 @@ from __future__ import print_function
</span>
import os
import configparser
<span style="color: #000000;background-color: #ffdddd">-from espeak import espeak
</span> from gi.repository import GLib
from gi.repository import IBus
from gi.repository import Pango
<span style="color: #999999">@@ -38,6 +37,40 @@ data_dir = "/usr/share/ibus-braille";
</span> home_dir = os.environ['HOME']
<span style="color: #000000;background-color: #ddffdd">+########################## Temporary fix ###################
+espeak_available = 0
+speechd_available = 0;
+try:
+ import speechd
+ speechd_available = 1;
+ client = speechd.Client()
+except:
+ try:
+ from espeak import espeak
+ espeak_available = 1;
+ except:
+ espeak_available = 0;
+
+
+def speak(text):
+ if(speechd_available):
+ client.speak(text);
+ elif (espeak_available):
+ espeak.synth(text)
+ else:
+ print("No tts api available!(python3-espeak/python3-speechd)");
+
+def set_language(language):
+ print(language)
+ if(speechd_available):
+ client.set_language(language)
+ elif (espeak_available):
+ espeak.set_voice(language)
+ else:
+ pass
+####### End of Temporary fix #############
+
+
</span> class EngineSharadaBraille(IBus.Engine):
__gtype_name__ = 'EngineSharadaBraille'
<span style="color: #999999">@@ -152,20 +185,20 @@ class EngineSharadaBraille(IBus.Engine):
</span> break;
count += 1
self.delete_surrounding_text(-(count),count);
<span style="color: #000000;background-color: #ffdddd">- espeak.synth(string_up_to_cursor[-(count):]+"Deleted")
</span><span style="color: #000000;background-color: #ddffdd">+ speak(string_up_to_cursor[-(count):]+"Deleted")
</span>
#If end is not space, delete length of last word
else:
count = len(string_up_to_cursor.split()[-1])
self.delete_surrounding_text(-(count),count);
<span style="color: #000000;background-color: #ffdddd">- espeak.synth(string_up_to_cursor.split()[-1]+"Deleted")
</span><span style="color: #000000;background-color: #ddffdd">+ speak(string_up_to_cursor.split()[-1]+"Deleted")
</span>
#Delete Last letter
elif (ordered_pressed_keys == "9"):
surrounding_text = self.get_surrounding_text()
text = surrounding_text[0].get_text()
<span style="color: #000000;background-color: #ffdddd">- espeak.synth(text[-1:]+"Deleted")
</span><span style="color: #000000;background-color: #ddffdd">+ speak(text[-1:]+"Deleted")
</span> self.delete_surrounding_text(-1,1);
#Toggle capital switch
<span style="color: #999999">@@ -173,10 +206,10 @@ class EngineSharadaBraille(IBus.Engine):
</span> if (self.capital_switch == 1):
if (self.capital == False):
self.capital = True
<span style="color: #000000;background-color: #ffdddd">- espeak.synth("Caps Lock On!")
</span><span style="color: #000000;background-color: #ddffdd">+ speak("Caps Lock On!")
</span> else:
self.capital = False
<span style="color: #000000;background-color: #ffdddd">- espeak.synth("Caps Lock Off!")
</span><span style="color: #000000;background-color: #ddffdd">+ speak("Caps Lock Off!")
</span> self.capital_switch = 0;
self.capital_switch = 1;
<span style="color: #999999">@@ -220,7 +253,7 @@ class EngineSharadaBraille(IBus.Engine):
</span>
def load_map(self,language_with_code):
self.language = language_with_code.split("-")[0]
<span style="color: #000000;background-color: #ffdddd">- espeak.set_voice(language_with_code.split("-")[1])
</span><span style="color: #000000;background-color: #ddffdd">+ set_language(language_with_code.split("-")[1])
</span> print ("loading Map for language : %s" %self.language)
self.map = {}
submap_number = 1;
<span style="color: #999999">@@ -243,7 +276,7 @@ class EngineSharadaBraille(IBus.Engine):
</span>
#Load abbreviations if exist
self.load_abbrivation();
<span style="color: #000000;background-color: #ffdddd">- espeak.synth("{} Loaded!".format(self.language));
</span><span style="color: #000000;background-color: #ddffdd">+ speak("{} Loaded!".format(self.language));
</span>
<span style="color: #999999">@@ -284,5 +317,5 @@ class EngineSharadaBraille(IBus.Engine):
</span> def __commit_string(self, text):
self.commit_text(IBus.Text.new_from_string(text))
if (len(text) > 1):
<span style="color: #000000;background-color: #ffdddd">- espeak.synth(text)
</span><span style="color: #000000;background-color: #ddffdd">+ speak(text)
</span>
</code></pre>
<br>
</li>
</div>
<div class='footer' style='margin-top: 10px;'>
<p>
—
<br>
<a href="https://gitlab.com/smc/ibus-braille/commit/a95477de02724de4e174a077850fa44b5d8849e0">View it on GitLab</a>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.com/smc/ibus-braille/commit/a95477de02724de4e174a077850fa44b5d8849e0"}}</script>
</p>
</div>
</body>
</html>