Keep the output stream open between playing back messages. This solves the problem of Naomi closing the stream after writing data to it, but before the data has been completely played back. It also should reduce "popping" for devices that "pop" when being opened and closed.
I implemented this in pyaudio. The same thing could probably be done in Alsa. I'll try copying the updated play_fp method from pyaudioengine.py to audiodevice.py and see what blows up when I try to use Alsa.
This update also contains a fix to the mic.py script which allows multi-word wakewords (like "Hey Naomi" or "Naomi Bot") to be used.
It is one way to prevent output from getting clipped at the end when the output stream gets closed before the file has finished playing. Other methods include adding a pause for the length of the recording (or the length of the recording minus the time that has passed since first starting to add audio chunks to the buffer).
How Has This Been Tested?
~/Naomi $ python -m unittest discover
Ran 25 tests in 19.288s
OK (skipped=12)
Screenshots (if appropriate):
Types of changes
[X] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
[X] My code follows the code style of this project.
[ ] My change requires a change to the documentation.
Description
Keep the output stream open between playing back messages. This solves the problem of Naomi closing the stream after writing data to it, but before the data has been completely played back. It also should reduce "popping" for devices that "pop" when being opened and closed.
I implemented this in pyaudio. The same thing could probably be done in Alsa. I'll try copying the updated play_fp method from pyaudioengine.py to audiodevice.py and see what blows up when I try to use Alsa.
This update also contains a fix to the mic.py script which allows multi-word wakewords (like "Hey Naomi" or "Naomi Bot") to be used.
Related Issue
Naomi's output audio gets clipped #365
Motivation and Context
It is one way to prevent output from getting clipped at the end when the output stream gets closed before the file has finished playing. Other methods include adding a pause for the length of the recording (or the length of the recording minus the time that has passed since first starting to add audio chunks to the buffer).
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: