1

I am using librosa to process audio file,

'good.wav' is a 30-second audio file

The code -

data, sampling_rate = librosa.load('good.wav', )
plt.figure(figsize=(12, 4))
librosa.display.waveplot(data, sr=sampling_rate)

Here, the sampling_rate = 22050

This above code results in the correct plot. enter image description here

Then, I changed the sampling_rate(frequency) to 60000

plt.figure(figsize=(12, 4))
librosa.display.waveplot(data, sr = 60000)

This code results in this plot: enter image description here

The above code works fine with the fact, frequency = 1/Time, The time is decreased when the frequency is increased.

After that, I resampled the audio,

samples = librosa.core.resample(data, sampling_rate, 60000)

It gives the "samples" variable with high values than the "data" variable. Actually, len(data) = 600000 and, len(samples) = 1800000

Then, I want to plot the "samples" values-

plt.figure(figsize=(12, 4))
librosa.display.waveplot(samples, sr = 60000)

which results in the following plot: enter image description here

But in this plot, the time is stable. Why the time is not reduced when the frequency is increased to 60000.

Thank you

SuperKogito
  • 2,998
  • 3
  • 16
  • 37
  • ... you resampled it to 60000 so now it has sampling rate 60000. Accordingly the plot will show the correct length with sampling rate 60000. – xdurch0 Oct 17 '19 at 14:15
  • I think,I understand correctly. Let me correct if I am not right. This code - librosa.display.waveplot(data, sr = 60000), "sr" makes the audio to shrink. So, the audio shrink from 30 seconds to 11 seconds. In this case, "sr" means frequency. – Shanmugaraj Kamaraj Oct 17 '19 at 17:03
  • And, another clarification - sampling rate and frequency are same thing or not. Because "sr" behave as frequency in the librosa.display function and, also behave as number of sampling values taken from the signal per second in resample( ) function. – Shanmugaraj Kamaraj Oct 17 '19 at 17:10

0 Answers0