简体   繁体   中英

Python utilizing file paths

sound_file_paths =[
    "/Users/ferhatkaygun/Desktop/UrbanSound8K/audio/fold1/57320-0-0-7.wav",
    "/Users/ferhatkaygun/Desktop/UrbanSound8K/audio/fold1/24074-1-0-3.wav",
    "/Users/ferhatkaygun/Desktop/UrbanSound8K/audio/fold1/15564-2-0-1.wav",
    "/Users/ferhatkaygun/Desktop/UrbanSound8K/audio/fold1/31323-3-0-1.wav",
    "/Users/ferhatkaygun/Desktop/UrbanSound8K/audio/fold1/46669-4-0-35.wav",
]    

sound_names = [
    "air conditioner",
    "car horn",
    "children playing",
    "dog         bark",
    "drilling",
    "engine idling",
    "gun shot",
    "jackhammer",
    "siren",
    "street music"
]

raw_sounds = load_sound_files(sound_file_paths)

Hey there, I am using librosa and I did not deal often with importing files into python programs.

How can I import the files without receiving that sound file paths is not defined? The Programm was first coded in python 2.7 but I use the current version on Mac Os. could that be a problem

you are getting the error that soundfiles are not defined because the program cannot find the file. Most likely the paths you are using are not from your machine?

you need to put the files to a directory, ex /Users/me/files/ on your machine and then replace the file paths in your script to point at this directory instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM