3

The problem im trying to solve is that i cant run Whisper model for some audio, it says something related to audio decoding. payload.wav: Invalid data found when processing input. raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e

I tried using the micro-machines.wav and it works fine but when i used other audio it gives me an error

import whisper

model = whisper.load_model("base")
text=model.transcribe('micro-machines.wav',fp16=False)
print(text)
text=model.transcribe('payload.wav',fp16=False)
print(text)

Error im getting for payload

d:\...\venv\lib\site-packages\whisper\transcribe.py:79: UserWarning: FP16 is not supported on CPU; using FP32 instead
  warnings.warn("FP16 is not supported on CPU; using FP32 instead")                                                                                        
Traceback (most recent call last):
  File "d:\...\venv\lib\site-packages\whisper\audio.py", line 42, in load_audio
    ffmpeg.input(file, threads=0)                                                                                    
  File "d:\...\venv\lib\site-packages\ffmpeg\_run.py", line 325, in run        
    raise Error('ffmpeg', out, err)                                                                                  
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)                                                       

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\....\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\.....\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\...\venv\Scripts\whisper.exe\__main__.py", line 7, in <module>
  File "d:\...\venv\lib\site-packages\whisper\transcribe.py", line 314, in cli
    result = transcribe(model, audio_path, temperature=temperature, **args)
  File "d:\...\venv\lib\site-packages\whisper\transcribe.py", line 85, in transcribe
    mel = log_mel_spectrogram(audio)
  File "d:\...\venv\lib\site-packages\whisper\audio.py", line 111, in log_mel_spectrogram
    audio = load_audio(audio)
  File "d:\...\venv\lib\site-packages\whisper\audio.py", line 47, in load_audio
    raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e
RuntimeError: Failed to load audio: ffmpeg version 6.0-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enab
le-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxv
id --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf 
--enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libo
pencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enab
le-librubberband
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
payload.wav: Invalid data found when processing input

i tried searching for solution and i found it says It appears that the code failed to load the audio file for some reason and even failed to display that error because e.stderr did not contain a valid UTF-8 string

if anyone can guide me it how i can solve this issue

Thank you

John mick
  • 31
  • 1
  • 2

2 Answers2

1

You must be sure that the audio file path is valid.

import whisper

model = whisper.load_model("base")

audioPath = "audios/me.m4a" # The path to your audio file must be correct.

result = model.transcribe(audioPath, fp16=False) 
print(result["text"])

More info : https://github.com/openai/whisper/discussions/301

Gedeon Mutshipayi
  • 2,871
  • 3
  • 21
  • 42
0

I ran into the same problem and it appeared to be just having the audio file named differently. In code I used *.mp3 and I had *.wav file recorded.

Also make sure you are running your Python code from inside the same directory you have your file in, it is considered as "root" then. To do so, simply cd into the directory from administrator powershell.

LubWn
  • 150
  • 1
  • 11