@@ -23,7 +23,6 @@ class EspeakDriver(object):
2323 _defaultVoice = ''
2424
2525 def __init__ (self , proxy ):
26- print ("[EspeakDriver.__init__] Initializing eSpeak Driver" )
2726 if not EspeakDriver ._moduleInitialized :
2827 # espeak cannot initialize more than once per process and has
2928 # issues when terminating from python (assert error on close)
@@ -119,40 +118,31 @@ def setProperty(name: str, value):
119118 raise KeyError ('unknown property %s' % name )
120119
121120 def save_to_file (self , text , filename ):
122- print ("[EspeakDriver.save to file] synth to file.. " )
123121 code = self .numerise (filename )
124122 _espeak .Synth (toUtf8 (text ), flags = _espeak .ENDPAUSE | _espeak .CHARS_UTF8 , user_data = code )
125123
126124 def _start_synthesis (self , text ):
127- print (f"[EspeakDriver._start_synthesis] Starting synthesis for text: { text } " )
128125 self ._proxy .setBusy (True )
129126 self ._proxy .notify ('started-utterance' )
130127 self ._speaking = True
131128 self ._data_buffer = b'' # Ensure buffer is cleared before starting
132129 try :
133- print (f"[EspeakDriver._start_synthesis] Calling eSpeak with text: { text } " )
134130 _espeak .Synth (toUtf8 (text ), flags = _espeak .ENDPAUSE | _espeak .CHARS_UTF8 )
135131 except Exception as e :
136- print (f"[EspeakDriver._start_synthesis] Error during speak: { e } " )
137132 self ._proxy .setBusy (False )
138133 self ._proxy .notify ('error' , exception = e )
139134 raise
140- finally :
141- print ("[EspeakDriver._start_synthesis] Finally block executed" )
142135
143136
144137 def _onSynth (self , wav , numsamples , events ):
145- print ("[EspeakDriver._onSynth] Called" )
146138 i = 0
147139 while True :
148140 event = events [i ]
149- print (f"[EspeakDriver._onSynth] Event type: { event .type } , Position: { event .text_position } , Length: { event .length } " )
150141 if event .type == _espeak .EVENT_LIST_TERMINATED :
151142 break
152143 if event .type == _espeak .EVENT_WORD :
153- self ._proxy .notify ('started-word' , location = event .text_position - 1 , length = event .length )
144+ self ._proxy .notify ('started-word' , location = event .text_position , length = event .length )
154145 elif event .type == _espeak .EVENT_END :
155- print ("[EspeakDriver._onSynth] EVENT_END" )
156146 stream = NamedTemporaryFile (delete = False , suffix = '.wav' )
157147
158148 try :
@@ -167,24 +157,14 @@ def _onSynth(self, wav, numsamples, events):
167157 os .system (f'ffmpeg -y -i { stream .name } { self .decode_numeric (event .user_data )} -loglevel quiet' )
168158 else :
169159 if platform .system () == 'Darwin' : # macOS
170- print (f"[EspeakDriver._onSynth] Playing sound on macOS... { stream .name } " )
171160 try :
172161 result = subprocess .run (['afplay' , stream .name ], check = True , capture_output = True , text = True )
173- print (f"[EspeakDriver._onSynth] afplay result: { result .returncode } " )
174- print (f"[EspeakDriver._onSynth] afplay stdout: { result .stdout } " )
175- print (f"[EspeakDriver._onSynth] afplay stderr: { result .stderr } " )
176- if result .returncode == 0 :
177- print (f"[EspeakDriver._onSynth] afplay completed successfully" )
178- else :
179- print (f"[EspeakDriver._onSynth] afplay failed with return code { result .returncode } " )
180162 except subprocess .CalledProcessError as e :
181- print (f"[EspeakDriver._onSynth] afplay failed with error: { e } " )
163+ raise RuntimeError (f"[EspeakDriver._onSynth] Mac afplay failed with error: { e } " )
182164 elif platform .system () == 'Linux' :
183165 os .system (f'aplay { stream .name } -q' )
184166 elif platform .system () == 'Windows' :
185- print (f"[EspeakDriver._onSynth] Playing sound on Windows... { stream .name } " )
186167 winsound .PlaySound (stream .name , winsound .SND_FILENAME ) # Blocking playback
187- print (f"[EspeakDriver._onSynth] Finished playing sound on Windows... { stream .name } " )
188168
189169 except Exception as e :
190170 raise RuntimeError (f"Error during playback: { e } " )
@@ -206,6 +186,7 @@ def _onSynth(self, wav, numsamples, events):
206186 if numsamples > 0 :
207187 self ._data_buffer += ctypes .string_at (wav , numsamples * ctypes .sizeof (ctypes .c_short ))
208188 return 0
189+
209190
210191 def endLoop (self ):
211192 self ._looping = False
@@ -234,7 +215,5 @@ def iterate(self):
234215 self ._proxy .setBusy (False )
235216 self .endLoop ()
236217
237-
238-
239218 def say (self , text ):
240219 self ._text_to_say = text
0 commit comments