Repository navigation
Fix audiodevice output buffer underrun error - #309
Merged
aaronchantrill merged 4 commits intoJan 13, 2021
Merged
Conversation
Just a slight change to the Naomi TTI scoring. After generating scores for all the intents, add those scores up and divide individual scores by the total. This makes the score always fall between 0 and 1 (currently there is no upper limit and I have seen scores as high as between 6 and 7). This should also make Naomi more confident in some cases. Right now if one intent scores .01 and all the other intents are zero, Naomi will respond with "unclear" since no intent has scored above .05 (5%). With this new system, .01/.01=1 (100%). I don't know if this will turn out to be a good thing or not. I think it will be good, but if it causes problems, we might need to add a filter before the conversion.
After the latest Raspbian Buster update on my Raspberry Pi 4, I was getting the following error message: ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred This was causing Naomi to make raspberry noises instead of talking when trying to play audio generated from flite. I tried increasing the chunk size in the profile.yml file, but it did not seem to affect the playback of a file in play_fp. It looks like the chunksize and output padding both get written to attributes of the audioengine plugin but I didn't see anywhere that they were actually passed to the play_file or play_fp audiodevice methods. Since we can read the profile directly from any method just by including the profile module, I'm just reading them directly from the play_fp method. Increasing the chunk size worked, but the audio kept getting clipped at the end. I tried enabling the padding option in profile.yml, but that didn't help. I ended up adding a new option under audio -> output_pause to have the computer pause after the last chunk is written to the device and before the stream is closed, and that finally worked. I set it to 0.5 seconds on my system which seemed to work fine. 0.1 was not enough to prevent clipping.
Closed
aaronchantrill
added a commit
to aaronchantrill/Naomi
that referenced
this pull request
Jan 23, 2021
In pull request NaomiProject#309, I removed the chunksize and add_padding optional parameters from play_fp, and pulled those values directly from the profile. This worked fine in normal operation, but introduced issues with the configuration routines in application.py which are passing parameters to play_file which are being passed along to play_fp. This update restores legacy compatibility by using *args and **kwargs to allow values to be passed in optionally, which makes it compatible with the call from play_file. If chunksize and add_padding are passed in as keyword arguments for some reason, those values are used instead of the profile values. In general, developers should not pass values directly to play_file or play_fp. I also removed the parameters from the play_file calls in application.py.
Merged
3 of 8 tasks
aaronchantrill
added a commit
that referenced
this pull request
Jan 23, 2021
In pull request #309, I removed the chunksize and add_padding optional parameters from play_fp, and pulled those values directly from the profile. This worked fine in normal operation, but introduced issues with the configuration routines in application.py which are passing parameters to play_file which are being passed along to play_fp. This update restores legacy compatibility by using *args and **kwargs to allow values to be passed in optionally, which makes it compatible with the call from play_file. If chunksize and add_padding are passed in as keyword arguments for some reason, those values are used instead of the profile values. In general, developers should not pass values directly to play_file or play_fp. I also removed the parameters from the play_file calls in application.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
After the latest Raspbian Buster update on my Raspberry Pi 4, I
was getting the following error message:
ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred
This was causing Naomi to make raspberry noises instead of
talking when trying to play audio generated from flite.
I tried increasing the chunk size in the profile.yml file, but
it did not seem to affect the playback of a file in play_fp. It
looks like the chunksize and output padding both get written to
attributes of the audioengine plugin but I didn't see anywhere
that they were actually passed to the play_file or play_fp
audiodevice methods. Since we can read the profile directly from
any method just by including the profile module, I'm just reading
them directly from the play_fp method.
Increasing the chunk size worked, but the audio kept getting
clipped at the end. I tried enabling the padding option in
profile.yml, but that didn't help. I ended up adding a new
option under audio -> output_pause to have the computer pause
after the last chunk is written to the device and before the
stream is closed, and that finally worked. I set it to 0.5
seconds on my system which seemed to work fine. 0.1 was not
enough to prevent clipping.
Related Issue
Buffer Underrun errors #308
Motivation and Context
I was experiencing buffer underrun errors when my Naomi was speaking using flite for tts, pyaudio for the audio engine and pulse for the audio device. This problem only showed up after the latest update of Raspbian.
How Has This Been Tested?
I tested on my Raspberry Pi 4. I ran the unittests afterwards and everything passed.
Types of changes
Checklist: