Failed to load audio: Cannot open shim file for read #1503
Unanswered
daytodatainc
asked this question in
Q&A
Replies: 1 comment 2 replies
-
u should read error message more throughly
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am unable to transcribe the audio to text using Jupyter. It works perfectly on Colab, but on my local machine it doesn't.
Code:
audio_files = []
for (r,d,f) in os.walk(audio_dir):
audio_files.append(f) #append the audio file name to the array
audio_files = audio_files[0]
print(f"There are {len(audio_files)} audio file(s) loaded")
for audio_file in audio_files:
result = model.transcribe(r"./audio_files/"+audio_file, fp16=False, language="en")
print(f"{audio_file} has been converted")
print(len(result['text']))
if len(result['text']) > 0:
split_values = audio_file.replace("CXone recording_","").replace("[UTC]","").split("_")[:3]
date_value = split_values[1]
time_value = split_values[2].replace("-",":")
person_value = split_values[0]
file_name = f"Type: {model_type} {date_value} - {time_value} - {person_value}.txt"
print(file_name)
full_file_name = f"./audio_files/audio_text/{file_name}"
Error:
Error Traceback (most recent call last)
File c:\users\cmw1s\appdata\local\programs\python\python38\lib\site-packages\whisper\audio.py:42, in load_audio(file, sr)
38 try:
39 # This launches a subprocess to decode audio while down-mixing and resampling as necessary.
40 # Requires the ffmpeg CLI and
ffmpeg-python
package to be installed.41 out, _ = (
---> 42 ffmpeg.input(file, threads=0)
43 .output("-", format="s16le", acodec="pcm_s16le", ac=1, ar=sr)
44 .run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True)
45 )
46 except ffmpeg.Error as e:
File c:\users\cmw1s\appdata\local\programs\python\python38\lib\site-packages\ffmpeg_run.py:325, in run(stream_spec, cmd, capture_stdout, capture_stderr, input, quiet, overwrite_output)
324 if retcode:
--> 325 raise Error('ffmpeg', out, err)
326 return out, err
Error: ffmpeg error (see stderr output for detail)
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
Cell In [4], line 14
9 #1. convert the audio file to text using Whisper
10 #2. create the text file
11 #3. save the text file in the audio_text directory
12 for audio_file in audio_files:
13 # convert the audio file to text
---> 14 result = model.transcribe(r"./audio_files/"+audio_file, fp16=False, language="en")
15 print(f"{audio_file} has been converted")
16 print(len(result['text']))
File c:\users\cmw1s\appdata\local\programs\python\python38\lib\site-packages\whisper\transcribe.py:84, in transcribe(model, audio, verbose, temperature, compression_ratio_threshold, logprob_threshold, no_speech_threshold, condition_on_previous_text, **decode_options)
81 if dtype == torch.float32:
82 decode_options["fp16"] = False
---> 84 mel = log_mel_spectrogram(audio)
86 if decode_options.get("language", None) is None:
87 if not model.is_multilingual:
File c:\users\cmw1s\appdata\local\programs\python\python38\lib\site-packages\whisper\audio.py:111, in log_mel_spectrogram(audio, n_mels)
109 if not torch.is_tensor(audio):
110 if isinstance(audio, str):
--> 111 audio = load_audio(audio)
112 audio = torch.from_numpy(audio)
114 window = torch.hann_window(N_FFT).to(audio.device)
File c:\users\cmw1s\appdata\local\programs\python\python38\lib\site-packages\whisper\audio.py:47, in load_audio(file, sr)
41 out, _ = (
42 ffmpeg.input(file, threads=0)
43 .output("-", format="s16le", acodec="pcm_s16le", ac=1, ar=sr)
44 .run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True)
45 )
46 except ffmpeg.Error as e:
---> 47 raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e
49 return np.frombuffer(out, np.int16).flatten().astype(np.float32) / 32768.0
RuntimeError: Failed to load audio: Cannot open shim file for read.
Could not read shim file.
Beta Was this translation helpful? Give feedback.
All reactions