I'm using Pydub in Python 3.4 to try to detect the pitch of some audio files.
I have a working pitch detection algorithm (McLeod Pitch Method), which is robust for real-time applications (I even made an Android pitch detection app with it: https://github.com/sevagh/Pitcha).
My issue is that I'm not getting any meaningful output from the algorithm when I apply it to AudioSegment._data.
Code:
from pydub import AudioSegmentsound = AudioSegment.from_wav(file="./8700hz.wav")#sampling rate = sound.frame_rate = 44100hz
mpm = Mpm(sound.frame_rate, len(sound._data))
print(mpm.get_pitch(sound._data))
Output:
Pitch: 150.000002396
If I play the same wav file from my speakers, record it from my microphone and apply the algorithm on the raw microphone capture (signed 16-bit little endian PCM, 44100Hz, mono), I get the correct pitch.
Does AudioSegment._data not return what I'm expecting?