Lofton Gentry
Lofton Gentry

Reputation: 313

FileNotFoundError in Jupyter Notebook, even though the file is there

This was all written in Jupyter Notebook online. What supposed to happen, is the first line of the code is a command that converts some file in the folder labeled "capstone" into an mp4. This works fine, however the problem I'm running into is a "FileNotFoundError", and I'm not sure why this is happening, as I check to see if the file is there, it is in fact there.

!ffmpeg -i recording1.mov -q:v 0 output.mp4

import librosa
audio_path = '/home/gentry/capstone/output1.mp4'
x , sr = librosa.load(audio_path)
print(type(x), type(sr))

import matplotlib.pyplot as plt
import librosa.display
plt.figure(figsize=(14, 5))

librosa.display.waveplot(x, sr=sr)

X = librosa.stft(x)
Xdb = librosa.amplitude_to_db(abs(X))
plt.figure(figsize=(14, 5))

librosa.display.specshow(Xdb, sr=sr, x_axis='time', y_axis='hz') 

librosa.display.specshow(Xdb, sr=sr, x_axis='time', y_axis='log')

The output should be a visualized waveform of a sound, and two subsequent Fourier transform graphs. I can provide additional details as requested

Upvotes: 1

Views: 969

Answers (2)

Lofton Gentry
Lofton Gentry

Reputation: 313

It is actually just a simple mistake of pathways being different, as this was provided to me by a professor, so audio_path = '/home/gentry/capstone/output1.mp4' should actually just be audio_path = './output1.mp4'

Upvotes: 0

kareem_emad
kareem_emad

Reputation: 1183

Ok, I will just make small modifications to your code to make all paths relative so the error may not be for wrong manual string path you wrote.

First I ran this command as is:

!ffmpeg -i recording1.mov -q:v 0 output.mp4

then to make sure that I have the output right

!ls | grep output

that should give you

output.mp4

Then as I know that the file is in the same directory as my notebook, I will make the load command as follows

import librosa
audio_path = './output.mp4'
x , sr = librosa.load(audio_path)
print(type(x), type(sr))

That works perfectly and loads the audio component, my figs maybe totally different than yours as I'm using some random video not your input one as it's not provided

enter image description here

Upvotes: 2

Related Questions