mimic1 icon indicating copy to clipboard operation
mimic1 copied to clipboard

Streaming with Portaudio on osX

Open maelp opened this issue 8 years ago • 3 comments

The streaming when running with -o stream seems broken, I'm building on osX and linking to PortAudio, the equivalent code using flite works fine, but I saw they did not use PortAudio so it might be due to that

It sounds a bit like the call to PortAudio is blocking in the same thread, and blocks the processing of the next chunk, are we supposed to create a audio thread when using PortAudio, and why is this not needed when using the streaming_info from original flite ?

maelp avatar Sep 12 '17 21:09 maelp

Thanks for the bug report and sorry for the late reply.

The PortAudio streaming functionality is not working (with -o stream), because I did not test that feature when I wrote the audio module. Sorry about that. Long story short I used the callback approach instead of the read/write method (both described in the PortAudio documentation).

While rewriting the PortAudio module in mimic is not very time consuming or difficult, the testing can take a while, so it may take a while for me to find time to implement the solution. Pull requests are welcome, though.

The steps I believe would work (in case you want to give it a try) are:

  • Open src/audio/au_portaudio.c
  • Set pa_callback to NULL and data to NULL in the Pa_OpenStream call. Remove the (now unused) data variable and remove as well the pa_callback static function from the beginning of the file.
  • Move the Pa_OpenStream and the Pa_StartStream calls from audio_write_portaudio to the end ofaudio_open_portaudio.
  • Move the Pa_StopStream call to audio_flush_portaudio. Move the Pa_CloseStream call to the beginning of audio_close_portaudio.
  • The audio_write_portaudio should be almost empty, the while loop has to be replaced with a single Pa_WriteStream call.
  • Test with -o stream and without.

zeehio avatar Oct 09 '17 11:10 zeehio

In the end I did it. It needs testing though. On my Linux system it works well.

Would you mind testing on your mac?

git clone https://github.com/MycroftAI/mimic
cd mimic
git checkout fix_portaudio_streaming
./configure --with-audio=portaudio --disable-vid_gb_ap
make # or make -j4 if you prefer
./mimic -voice slt -o stream doc/alice
# Press ctrl+c to cancel the streaming
./mimic -voice slt doc/alice
# Press ctrl+c to cancel 

zeehio avatar Oct 09 '17 16:10 zeehio

Thank you

maelp avatar Oct 09 '17 19:10 maelp