asha_mail has asked for the wisdom of the Perl Monks concerning the following question:

How can I compare two .wav files like checking the frequency and length using perl?

Replies are listed 'Best First'.
Re: Compare wav files
by tobyink (Canon) on Apr 17, 2012 at 12:41 UTC
    use 5.010; use Audio::Wav; my $file1 = Audio::Wav->read("file1.wav"); my $file2 = Audio::Wav->read("file2.wav"); say "Files same length (in seconds)" if $file1->length_seconds == $file2->length_seconds; say "Files same sample rate" if $file1->details->{sample_rate} == $file2->details->{sample_rate};
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Compare wav files
by icoder (Novice) on Apr 18, 2012 at 08:37 UTC

    The package Audio::Analyze work for your requirement, using Audio::Analyze get the SampleRate/Frequency of file which need to be compared and do whatever you want,

    And also consider using Audio::Wav::Read

    If you want to write your own script to get sample rate , read about wav file header information ie available first 44 bytes of generic pcm wav file, https://ccrma.stanford.edu/courses/422/projects/WaveFormat/