This Python script cannot find the specified file even though I have confirmed that the path is accurate. I've also tried referencing this same file with other scripts and did not run into this error. Any reason why this would happen?
Error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
[Finished in 1.5s with exit code 1]
Error when intentionally breaking the file link:
FileNotFoundError: [Errno 2] No such file or directory:
'C:\\Users\\[name]\\Desktop\\BREAKslide14.mp3'
import speech_recognition as sr
from os import path
from pydub import AudioSegment
AudioSegment.converter = r"C:\Users\[name]\Downloads\ffmpeg-20200603-b6d7c4c-win64-static\ffmpeg-20200603-b6d7c4c-win64-static\bin\ffmpeg.exe"
# convert mp3 file to wav
file = r"C:\Users\[name]\Desktop\slide14.mp3"
sound = AudioSegment.from_mp3(file)
sound.export("transcript.wav", format="wav")
# transcribe audio file
AUDIO_FILE = "transcript.wav"
# use the audio file as the audio source
r = sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
audio = r.record(source) # read the entire audio file
print("Transcription: " + r.recognize_google(audio))