I'm trying to make simple beamforming system with two USB microphone, and succeeded connecting both with a computer. Here is my code.
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)
Now, my problem is that I can't calculate beamforming sound using two data (input_wave1, input_wave2). Is it possible that with only a few edits, or is there another way? My goal is to run this code from raspberry pi. I'm sorry about my poor English.