Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 PyAudio
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DtY




PostPosted: Sat Nov 07, 2009 4:23 pm   Post subject: PyAudio

All I need to do is read raw samples from the microphone, and I've come across PyAudio. When I go through the microhpone to wav file tutorial I get an error, I have no idea at all what it means.

Python:
>>> import pyaudio
>>> p = pyaudio.PyAudio()
>>> stream = p.open(format=pyaudio.paInt16,channels=1,rate=44100,input=True,frames_per_buffer=1024)
>>> stream.read(1024)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyaudio.py", line 564, in read
    return pa.read_stream(self._stream, num_frames)
IOError: [Errno Input overflowed] -9981
>>>


Anyone have any idea what's going on? I'm on Mac OS 10.6 (snow leopard), Python 2.6, btw. Another library that would let me read raw samples from a microphone would work too, it needs to at least work on OS X, and cross platform would be better.
Sponsor
Sponsor
Sponsor
sponsor
handsome-music




PostPosted: Thu Nov 19, 2009 9:03 pm   Post subject: Re: PyAudio

I just installed PyAudio tonight and ran into the same problem. I was able to handle the error by wrapping the call to stream.read(chunk) in a try/except statement to catch any dropped frames gracefully, without exiting. For example:

Python:

try:
      data = stream.read(chunk)
except IOError:
      print 'warning: dropped frame' # can replace with 'pass' if no message desired


Let me know if that works for you.
zizou1304




PostPosted: Wed Jan 06, 2010 8:55 am   Post subject: Re: PyAudio

Python:
>>> import pyaudio
>>> p = pyaudio.PyAudio()
>>> stream = p.open(format=pyaudio.paInt16,channels=1,rate=44100,input=True,frames_per_buffer=1024)
>>> stream.read(1024)


hi
don't write code step by step in the python shell.
pyaudio need to be launched from a script.

just after you create the stream, a buffer begins to keep input data.
when you read 1024, it's too late, the buffer is overflowed.

when you launch the same code from a script, the execution is faster, and may success.

you can have something like that :
Python:

while not stop:
   try:
        x = self.stream.read(1024)   
    except IOError,e:
         if e[1] == pyaudio.paInputOverflowed:
              print e
              x = '\x00'*16*256*2 #value*format*chunk*nb_channels
                   
muneeb.ahmad




PostPosted: Sat May 07, 2011 2:56 am   Post subject: RE:PyAudio

Hi every one !

I am facing some peculiar problem with pyaudio!

I have used Pyaudio to implement VoIP chat module. and it is working fine as well when i connects to the internet through WiFi but when i connects two computers through LAN or Internet a dail up. I am receiving a peculiar kind of sound which is very odd .. I can hear my voice as well as that peculiar sound Can any one help me what can be the reason for it because i am stuck.

Thank you!
dayaramb




PostPosted: Tue Oct 18, 2011 2:59 am   Post subject: Re: PyAudio

hello, muneeb.ahmad,
Could you please let me know , how do you implement the pyaudio for voip chat . I am also trying the same thing for python audio chat.
Thank you !
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: