2015-11-03 04:38:59 -06:00
|
|
|
from __future__ import absolute_import
|
2014-10-27 16:29:04 -06:00
|
|
|
import ctypes
|
2015-11-03 04:38:59 -06:00
|
|
|
from .base import Output
|
2014-10-27 16:29:04 -06:00
|
|
|
|
|
|
|
class PCTalker(Output):
|
|
|
|
lib32 = 'pctkusr.dll'
|
|
|
|
lib64 = 'pctkusr64.dll'
|
2015-11-03 04:38:59 -06:00
|
|
|
cdll = True
|
|
|
|
argtypes = {
|
|
|
|
'PCTKPRead': (ctypes.c_char_p, ctypes.c_int, ctypes.c_int)
|
|
|
|
}
|
2014-10-27 16:29:04 -06:00
|
|
|
|
|
|
|
def speak(self, text, interrupt=False):
|
|
|
|
if interrupt:
|
|
|
|
self.silence()
|
2015-11-03 04:38:59 -06:00
|
|
|
self.lib.PCTKPRead(text.encode('cp932', 'replace'), 0, 1)
|
2014-10-27 16:29:04 -06:00
|
|
|
|
|
|
|
def silence(self):
|
|
|
|
self.lib.PCTKVReset()
|
|
|
|
|
|
|
|
def is_active(self):
|
|
|
|
return self.lib.PCTKStatus() != 0
|
|
|
|
|
|
|
|
output_class = PCTalker
|