Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add exception_on_overflow=False to pyaudio read calls #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions piclap/_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def __setInputDevice(self):

def readData(self):
"""Reads a single chunk of binary data from stream"""
return self.stream.read(self.config.chunk_size)
return self.stream.read(self.config.chunk_size, exception_on_overflow = False)

def openStream(self):
"""Open as binary stream to receive audio signals from microphone"""
Expand Down Expand Up @@ -194,8 +194,8 @@ def calibrateBufferSize(self, enabled=True):
try:
self.openStream()
for count in range(totalSamples):
data = self.stream.read(newChunkSize)
byte_stream = array('b', [0]) if data == None else data
data = self.stream.read(newChunkSize, exception_on_overflow = False)
byte_stream = array('b', [0]) if data == None or data == b'' else data
maximum = max(array('h', byte_stream))
self.maxSamples.append(maximum)
self.__printProgress(count+1, totalSamples)
Expand Down