I am a python newbie and am trying to generate subtitles from mp4 files in python using whisper-timestamped library. I keep getting "[WinError 2] The system cannot find the file specified" when I try this code:
audio = whisper_timestamped.load_audio(videofile)
The weird part is that I tried opening the mp4 file using moviepy to change it to audio just to check if its accessed and it worked fine and the code was able to save the audio file afterwards.
This is the full error code:
FileNotFoundError Traceback (most recent call last)
Cell In[6], line 1
----> 1 audio = whisper_timestamped.load_audio("bausenvid.mp4")
2 model = whisper_timestamped.load_model('base',device='gpu')
3 results = whisper_timestamped.transcribe(model,audio,language='en')
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\whisper\audio.py:58, in load_audio(file, sr)
56 # fmt: on
57 try:
---> 58 out = run(cmd, capture_output=True, check=True).stdout
59 except CalledProcessError as e:
60 raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e
File ~\AppData\Local\Programs\Python\Python310\lib\subprocess.py:501, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
498 kwargs['stdout'] = PIPE
499 kwargs['stderr'] = PIPE
--> 501 with Popen(*popenargs, **kwargs) as process:
502 try:
503 stdout, stderr = process.communicate(input, timeout=timeout)
File ~\AppData\Local\Programs\Python\Python310\lib\subprocess.py:966, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
962 if self.text_mode:
963 self.stderr = io.TextIOWrapper(self.stderr,
964 encoding=encoding, errors=errors)
--> 966 self._execute_child(args, executable, preexec_fn, close_fds,
967 pass_fds, cwd, env,
968 startupinfo, creationflags, shell,
969 p2cread, p2cwrite,
970 c2pread, c2pwrite,
971 errread, errwrite,
972 restore_signals,
973 gid, gids, uid, umask,
974 start_new_session)
975 except:
976 # Cleanup if the child failed starting.
977 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~\AppData\Local\Programs\Python\Python310\lib\subprocess.py:1435, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session)
1433 # Start the process
1434 try:
-> 1435 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1436 # no special security
1437 None, None,
1438 int(not close_fds),
1439 creationflags,
1440 env,
1441 cwd,
1442 startupinfo)
1443 finally:
1444 # Child is launched. Close the parent's copy of those pipe
1445 # handles that only the child should have open. You need
(...)
1448 # pipe will not close when the child process exits and the
1449 # ReadFile will hang.
1450 self._close_pipe_fds(p2cread, p2cwrite,
1451 c2pread, c2pwrite,
1452 errread, errwrite)
FileNotFoundError: [WinError 2] The system cannot find the file specified
The online forums suggested including the file directory, I tried that but nothing changed.