rhasspy / wyoming-snd-external

Wyoming protocol server that calls an external program to play audio
MIT License
12 stars 10 forks source link

AsyncEventHandler expects disconnect method. #2

Closed mrichar1 closed 8 months ago

mrichar1 commented 9 months ago

Wyoming's AsyncEventHandler base class defines disconnect not disconnected method: https://github.com/rhasspy/wyoming/blob/master/wyoming/server.py#L40

With this fixed, self._stop_proc is now called when the client disconnects, preventing stale command processes.

EDIT: It looks like this fix can cause the command to be terminated while still playing audio. I'm not sure of any way to 'know' that the command is safe to be terminated. The only approach I can think of is to refactor this module to match wyoming-mic-external and run a single long-running 'global' command at start.

mrichar1 commented 9 months ago

I've just realised that instead of calling terminate() on the process, it is better to use stdin.write_eof(). aplay will then play through all buffered audio before shutting itself down.

synesthesiam commented 8 months ago

This is a good idea. Thanks!