1

I'm extracting raw audio from a .flac file(youtube link - https://youtu.be/--BfvyPmVMo , extracting 10sec from this) and storing it as np-array float32. Getting nan, and extremely low and high values = [-8.63468980e+30 -9.76911766e+34 -1.93298665e+37 -2.69400132e+38 .... 2.33467619e-38 5.71834450e-39 6.70703932e-38 7.58865403e-36].

On this when I try to get melspectrogram then it gives an error -

TypeError: array([nan, nan, nan, ..., nan, nan, nan], dtype=float32) has type numpy.ndarray, but expected one of: int, long, float

To extract raw audio using(this is similar to what is done in dmvr lib, https://github.com/deepmind/dmvr/blob/master/examples/generate_from_file.py)

cmd = (
      ffmpeg
      .input(video_path, ss=start, t=end-start)
      .output("pipe:", ac=1, ar=sampling_rate, format="s32le")
  )

  audio, _ = cmd.run(capture_stdout=True, quiet=True)

  audio = np.frombuffer(audio, np.float32) "

To get melspectrogram -

mel_spec = librosa.feature.melspectrogram(audio,sr=16000,hop_length=10,n_mels=128,window=25)

Errors

C:\Users\Shreya Gupta\IS-Project\generate_from_file.py:142: FutureWarning: Pass y=[-6.5381321e+37  1.5676004e-38  7.2428216e-37 ...  2.6283893e-37
  2.5346798e-36  1.9253581e-37] as keyword args. From version 0.10 passing these as positional arguments will result in an error
  mel_spec = librosa.feature.melspectrogram(audio,sr=16000,hop_length=10,n_mels=128,window=25)
C:\ProgramData\Anaconda3\lib\site-packages\librosa\core\spectrum.py:2563: RuntimeWarning: overflow encountered in absolute
  np.abs(
C:\ProgramData\Anaconda3\lib\site-packages\librosa\core\spectrum.py:2563: RuntimeWarning: overflow encountered in square
  np.abs().....
TypeError: array([nan, nan, nan, ..., nan, nan, nan], dtype=float32) has type numpy.ndarray, but expected one of: int, long, float

Could someone please help, thank you!

rickhg12hs
  • 10,638
  • 6
  • 24
  • 42
Shreya Gupta
  • 97
  • 2
  • 8
  • [Please don't use images for code/errors/tracebacks/logs/etc.](https://meta.stackoverflow.com/a/285557/1409374) Just cut/paste into code block. http://idownvotedbecau.se/imageofcode – rickhg12hs Feb 17 '23 at 19:50

0 Answers0