|
18 | 18 | @author: Diego Torres Milano |
19 | 19 | ''' |
20 | 20 |
|
21 | | -__version__ = '15.2.2' |
| 21 | +__version__ = '15.2.3' |
22 | 22 |
|
23 | 23 | import sys |
24 | 24 | import warnings |
|
107 | 107 | TEXT_PROPERTY = 'text:mText' |
108 | 108 | TEXT_PROPERTY_API_10 = 'mText' |
109 | 109 | 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 |
111 | 111 | TAG_PROPERTY = 'getTag()' |
112 | 112 | LEFT_PROPERTY = 'layout:mLeft' |
113 | 113 | LEFT_PROPERTY_API_8 = 'mLeft' |
@@ -3883,21 +3883,29 @@ def setText(self, v, text): |
3883 | 3883 | # v.type(text) |
3884 | 3884 |
|
3885 | 3885 | @staticmethod |
3886 | | - def sayText(text, voice=None): |
| 3886 | + def sayText(text, voice=None, verbose=False): |
3887 | 3887 | 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) |
3888 | 3893 | if DEBUG: |
3889 | 3894 | print >> sys.stderr, 'Saying "%s" using festival' % text |
3890 | | - time.sleep(2) |
3891 | 3895 | pipe = subprocess.Popen(['/usr/bin/festival']) |
3892 | 3896 | pipe.communicate('(SayText "%s")' % text) |
3893 | 3897 | pipe.terminate() |
3894 | 3898 | time.sleep(5) |
3895 | 3899 | 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) |
3898 | 3904 | time.sleep(1) |
3899 | 3905 | if not voice: |
3900 | 3906 | voice = 'Samantha' |
| 3907 | + if DEBUG: |
| 3908 | + print >> sys.stderr, 'Saying "%s" as %s' % (text, voice) |
3901 | 3909 | subprocess.check_call(['/usr/bin/say', '-v', voice, text]) |
3902 | 3910 | time.sleep(5) |
3903 | 3911 | else: |
|
0 commit comments