Skip to content

Commit 05df253

Browse files
committed
Added verbose parameter to sayText()
1 parent 9fbbb61 commit 05df253

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/com/dtmilano/android/viewclient.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '15.2.2'
21+
__version__ = '15.2.3'
2222

2323
import sys
2424
import warnings
@@ -107,7 +107,7 @@
107107
TEXT_PROPERTY = 'text:mText'
108108
TEXT_PROPERTY_API_10 = 'mText'
109109
TEXT_PROPERTY_UI_AUTOMATOR = 'text'
110-
WS = u"\xfe" # the whitespace replacement char for TEXT_PROPERTY
110+
WS = u"\xfe" # the whitespace replacement char for TEXT_PROPERTY
111111
TAG_PROPERTY = 'getTag()'
112112
LEFT_PROPERTY = 'layout:mLeft'
113113
LEFT_PROPERTY_API_8 = 'mLeft'
@@ -3883,21 +3883,29 @@ def setText(self, v, text):
38833883
# v.type(text)
38843884

38853885
@staticmethod
3886-
def sayText(text, voice=None):
3886+
def sayText(text, voice=None, verbose=False):
38873887
if ViewClient.isLinux:
3888+
if verbose:
3889+
# FIXME: should use Colors, but for now it's fine
3890+
# print in magenta (35)
3891+
print "\x1b[{}{}m>> saying: {}\x1b[0m".format(35, '', text)
3892+
time.sleep(2)
38883893
if DEBUG:
38893894
print >> sys.stderr, 'Saying "%s" using festival' % text
3890-
time.sleep(2)
38913895
pipe = subprocess.Popen(['/usr/bin/festival'])
38923896
pipe.communicate('(SayText "%s")' % text)
38933897
pipe.terminate()
38943898
time.sleep(5)
38953899
elif ViewClient.isDarwin:
3896-
if DEBUG:
3897-
print >> sys.stderr, 'Saying "%s"' % text
3900+
if verbose:
3901+
# FIXME: should use Colors, but for now it's fine
3902+
# print in magenta (35)
3903+
print "\x1b[{}{}m>> saying: {}\x1b[0m".format(35, '', text)
38983904
time.sleep(1)
38993905
if not voice:
39003906
voice = 'Samantha'
3907+
if DEBUG:
3908+
print >> sys.stderr, 'Saying "%s" as %s' % (text, voice)
39013909
subprocess.check_call(['/usr/bin/say', '-v', voice, text])
39023910
time.sleep(5)
39033911
else:

0 commit comments

Comments
 (0)