Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written) OpenAssistant Conversations (oasst2)
Write a python code that lists all audio files in a directory in seconds.
0
DownloadIn OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
Write a python code that lists all audio files in a directory in seconds.
- Assistant
Sure, you can first list all the files then select the audio files.
Here is how to list all the files (the runtime will depend on how many files you have):
from os import listdir from os.path import isfile, join onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]Now you can filter
onlyfilesto only keep audio files, to do that tell me which extensions you expect (such as ".mp3", ".wav", etc.) - User
Can this be applied to any extention such as a jpg, bmp, txt? Or just music?
- Assistant
It can be applied to any set of files you wish as long as you know the extension. So if a text file has the somewhat more rare used extension asc, then you will not find it, if you are only looking for ".txt".