forked from Amerikranian/AudioGame-Sample-with-Pyglet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
speech.py
30 lines (30 loc) · 993 Bytes
/
speech.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from accessible_output2.outputs.auto import Auto
from accessible_output2.outputs import auto
def find_tts():
screen_readers=["Dolphin","jaws","NVDA","Unnamed Output","VoiceOver","Window-Eyes"]
outputs=Auto().outputs
sr=None
for possible_output in outputs:
if not possible_output.name in screen_readers: #revirce for sapi
continue
if possible_output.is_active():
sr=possible_output
return sr
def find_reader():
screen_readers=["Dolphin","jaws","NVDA","Unnamed Output","VoiceOver","Window-Eyes"]
outputs=Auto().outputs
sr=None
for possible_output in outputs:
if not possible_output.name in screen_readers: continue
if possible_output.is_active(): sr=possible_output
if sr==None:
for possible_output in outputs:
if possible_output.name in screen_readers: continue
if possible_output.is_active(): sr=possible_output
return sr
def speak(text, interrupt=True):
global tts
if not tts or not tts.is_active():
tts=find_reader()
tts.speak(text, interrupt)
tts=None