crossing = [math.copysign(1.0, s) for s in signal]
index = find(np.diff(crossing))
f0 = round(len(index) * RATE / (2 * np.prod(len(signal))))
return f0
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True,
    output=True, frames_per_buffer=chunk)
for i in range(0, RATE / chunk * RECORD_SECONDS):
    data = stream.read(chunk)
Frequency = Pitch(data)
print('%f Frequency' % Frequency)
Frequency Analysis in Python