Last active
February 7, 2019 21:31
-
-
Save srsani/5ee3a6bd5c8b6f2afed80a2cd36c8a73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import pydub | |
import pandas as pd | |
import glob | |
def con_mp3_wav(file): | |
sound = pydub.AudioSegment.from_mp3(file) ## reading the file mp3 file | |
sound.export(file[:-4]+".wav", format="wav")## exporting the wav fiel to a spesific folder. | |
## file[:-4] removes the .mp3 from the file name. | |
dic['id'].append(int(file[:-4])) | |
dic['frame_rate'].append(sound.frame_rate) | |
dic['lenght'].append(len(sound)) | |
if __name__ == '__main__': | |
dic = {'id': [], 'frame_rate':[] , 'lenght':[]} ## making a dictionary for metafiles | |
files = glob.glob("*.mp3") ## reading all the files name to in to a list | |
for file in files: | |
con_mp3_wav(file) | |
df = pd.DataFrame.from_dict(dic) ## saveing the file name, frame rate and lenght to a datafrem | |
df.to_csv("metadata.csv") ## savign the data frame to a csv file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment