NaomiProject / Naomi

The Naomi Project is an open source, technology agnostic platform for developing always-on, voice-controlled applications!
https://projectnaomi.com/
MIT License
242 stars 47 forks source link

Keep output stream open #366

Closed aaronchantrill closed 1 year ago

aaronchantrill commented 1 year ago

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?

~/Naomi $ python -m unittest discover
Ran 25 tests in 19.288s

OK (skipped=12)

Screenshots (if appropriate):

Types of changes

Checklist: