I'm trying to set up this guitar tab transscriptor, but ran into a problem with the path not being defined. As you can see in the code, i tried to set the path to r'C:\Users\Bruger\Desktop\GuitarSet\audio\audio_hex-pickup_original'
and so on. I don't have that much coding experience, and was simply just following an online tutorial, but i would really like to know whats wrong here. Thanks in advance
path = r'C:\Users\Bruger\Desktop\GuitarSet\audio\audio_hex-pickup_original'
audio_file = os.listdir(path)
audio_path = os.path.join(path, audio_file[file_num])
# Function for removing noise
def cqt_lim(CQT):
new_CQT = np.copy(CQT)
new_CQT[new_CQT < -60] = -120
return new_CQT
# Perform the Constant-Q Transform
data, sr = librosa.load(audio_path, sr = None, mono = True, offset = start, duration = dur)
CQT = librosa.cqt(data, sr = 44100, hop_length = 1024, fmin = None, n_bins = 96, bins_per_octave = 12)
CQT_mag = librosa.magphase(CQT)[0]**4
CQTdB = librosa.core.amplitude_to_db(CQT_mag, ref = np.amax)
new_CQT = cqt_lim(CQTdB)
---------------------------------------------------------------------------
**NameError Traceback (most recent call last)
<ipython-input-45-144a3248f390> in <module>
14
15 # Perform the Constant-Q Transform
---> 16 data, sr = librosa.load(audio_path, sr = None, mono = True, offset = start, duration = dur)
17 CQT = librosa.cqt(data, sr = 44100, hop_length = 1024, fmin = None, n_bins = 96, bins_per_octave = 12)
18 CQT_mag = librosa.magphase(CQT)[0]**4
NameError: name 'audio_path' is not defined**
Maybe it has to do with the indentation of audio_path
and audio_file
.
Is it possible to see some previous code?