forked from mar5chi/hand_gesture_control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpeechController.py
29 lines (26 loc) · 975 Bytes
/
SpeechController.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
import subprocess
import os
import signal
class SpeechController:
""" This class handles the speech output to give an auditive feedback to the user's input. """
def __init__(self):
self.pid = None
self.proc = None
#------------------------------------------------
#print(f'SpeechController pid: {self.pid}')
#------------------------------------------------
def say(self, text):
#print(f'SpeechController say(): {text}')
#print(f'SpeechController os.getpid(): {os.getpid()}')
p = subprocess.Popen(["espeak","-s180 -ven+18 -z",text])
p.daemon = True
#print(p)
#print(f'SpeechController say() p.pid: {p.pid}')
self.proc = p
self.pid = p.pid
def kill_proc(self):
if self.pid is not None:
#print(f'SpeechController kill_proc(): {self.pid}')
os.kill(self.pid, signal.SIGKILL)
self.pid = None
self.proc = None