我正在尝试使用两个USB麦克风制作简单的波束成形系统,并成功连接计算机。这是我的代码。
import numpy as np
from scipy.io import wavfile
import time
import pyaudio
import matplotlib.pyplot as plt
import wave
p = pyaudio.PyAudio()
FORMAT = pyaudio.paInt16
def callback1(in_data, frame_count, time_info, flag):
input_wave1 = np.fromstring(in_data, 'Float32')
return (input_wave1,pyaudio.paContinue)
def callback2(in_data, frame_count, time_info, flag):
input_wave2 = np.fromstring(in_data, 'Float32')
return (input_wave2,pyaudio.paContinue)
CHANNELS = 1
RATE = 22050
buffer_size = 200
stream1 = p.open(format=FORMAT,
channels=CHANNELS,
frames_per_buffer = buffer_size,
rate=RATE,
output=True,
input=True,
input_device_index = 1,
stream_callback = callback1)
stream2 = p.open(format = FORMAT,
channels = CHANNELS,
frames_per_buffer = buffer_size,
rate = RATE,
output=True,
input = True,
input_device_index = 2,
stream_callback = callback2)
现在,我的问题是我无法使用两个数据(input_wave1,input_wave2)计算波束成形声音。是否有可能只进行少量编辑,还是有其他方式?我的目标是从raspberry pi运行此代码。对于我的英语不好,我很抱歉。