Question

I’m currently developing a little project involving microphone input in Python and I’m using PyAudio library (binding for PortAudio). As I try the first « Wire » example (blocking), everything work flawlessly, but as soon as I try running the second example, « Wire (callback) », Python says :

Traceback (most recent call last):
  File "main.py", line 24, in <module>
    stream_callback=callback)
TypeError: __init__() got an unexpected keyword argument 'stream_callback'

While it is correctly defined in the binding. Any help on this ?

The complete code is :

import pyaudio
import time

WIDTH = 2
CHANNELS = 2
RATE = 44100

p = pyaudio.PyAudio()

def callback(in_data, frame_count, time_info, status):
    return (in_data, pyaudio.paContinue)

stream = p.open(format=p.get_format_from_width(WIDTH),
                channels=CHANNELS,
                rate=RATE,
                input=True,
                output=True,
                stream_callback=callback)

stream.start_stream()

while stream.is_active():
    time.sleep(0.1)

stream.stop_stream()
stream.close()

p.terminate()

Thanks !

Était-ce utile?

La solution

Updating PyAudio and PortAudio solved the problem.

Autres conseils

it doesn't look like stream_callback in a valid arg on Mac OSX installations of PyAudio :(

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top