我一直在用下面的代码录制音频
bytes = 1024
format = pyaudio.paInt16
channels = 1
outputFile = "C:/python27/test.wav"
rate = 12000
audioRecorder = pyaudio.PyAudio()
recorder = audioRecorder.open(format = format, channels = channels, rate = rate, input = True, frames_per_buffer = bytes)
for i in range(0, int(rate/bytes * duration)):
data = recorder.read(bytes)
myArr.append(data)
recorder.stop_stream()
recorder.close()
audioRecorder.terminate()
myArr
“myArr”是什么类型的数据类型?如何将其转换为具有浮点值的数组
编辑------------------------------------------
我发现“myArr”是一个类似这样的列表
00: [b'\x01\x00\x04.....
01: [b'\x01\x00\xfb.....
但我希望它是一个带有单浮点值的数组。我一直在尝试使用numpy.array,但我无法解决我的问题
变量my myArr是字节数组。您可以使用
它获取每个值,然后将其转换回整数。如果要使用无符号整数,请更改
到
相关问题 更多 >
编程相关推荐