AttributeError:'module'对象没有属性'paInt16'

时间:2016-01-13 01:34:46

标签: python module attributes pyaudio

我试图在我的覆盆子pi 2模型B上使用最新版本的pyaudio与jasper一起工作。当我试图让它在jasper中运行它有一个采样率问题,我已经缩小到pyaudio问题

当我运行测试示例时:

import pyaudio
import wave

CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"

p = pyaudio.PyAudio()

stream = p.open(format=FORMAT,
            channels=CHANNELS,
            rate=RATE,
            input=True,
            frames_per_buffer=CHUNK)

print("* recording")

frames = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data)

print("* done recording")

stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()

我收到此错误:

AttributeError: 'module' object has no attribute 'paInt16'

我已经尝试重新安装等但无济于事

0 个答案:

没有答案