I want to find the number of frames in wav file between certain time range that is generally using the function wave.getnframes we can get the number of frames in the complete wave file but here i want to know how to find the number frames between a certain time range such number of frames between 5.43 sec to 5.81 secs..
how can we do this??
please suggest ways to do thi开发者_开发问答s...
thanks in advance
frame rate is equal to the number of frames per a second so 5.81 minus 5.43 equals 0.38 seconds number of frames is equal to 0.38 * wave.getframerate() Like so:
import wave
start_time = 5.43
stop_time = 5.81
time_period = stop_time - start_time
wav = wave.open('test.wav')
time_period_frames = time_period * wav.getnframes()
Sometimes it is easier to figure these things out by starting a python interactive session at the command line by typing 'python' all by itself.
This is how I figured it out I created a 60 second clip. Then I divided wave.getnframes() by wave.getframerate(). The result was 60. The docs don't spell this out because it is common knowledge in multimedia. But it always pays to check twice.
精彩评论