# HG changeset patch # User Emmanouil Theofanis Chourdakis # Date 1507546503 -3600 # Node ID b7b1672b3c3b282134ee366a974d9c43e16652c2 # Parent a8e3d63653b65461f33622e60a5f6addb9bc8020 Reading and writing of files now is done by soundfile since there seems to be a bug with writing .wav files with librosa (mplayer would play them as rubbish). Added soundfile as a requirement. diff -r a8e3d63653b6 -r b7b1672b3c3b python/requirements.txt --- a/python/requirements.txt Sun Oct 08 15:23:50 2017 +0100 +++ b/python/requirements.txt Mon Oct 09 11:55:03 2017 +0100 @@ -4,3 +4,4 @@ librosa matplotlib tabulate +soundfile diff -r a8e3d63653b6 -r b7b1672b3c3b python/simscene.py --- a/python/simscene.py Sun Oct 08 15:23:50 2017 +0100 +++ b/python/simscene.py Mon Oct 09 11:55:03 2017 +0100 @@ -22,7 +22,10 @@ # Librosa import librosa import librosa.display -import librosa.output + +# PySoundfile + +import soundfile as sf # Matplotlib import matplotlib.pyplot as plt @@ -73,7 +76,7 @@ candidates = glob.glob('{}/event/{}*wav'.format(input_path, sampleid)) chosen_fname = random.sample(candidates, 1)[0] - wav, SR = librosa.load(chosen_fname, sr=sr) + wav, SR = sf.read(chosen_fname) else: chosen_fname = random.sample(candidates, 1)[0] @@ -365,7 +368,7 @@ # If no patterns are found, search for normal audio files candidates = glob.glob('{}/background/{}*.wav'.format(input_path, backgrounds_df['sampleid'].loc[n])) chosen_fname = random.sample(candidates, 1)[0] - wav, sr = librosa.load(chosen_fname, sr=SR) + wav, sr = sf.read(chosen_fname) else: chosen_fname = random.sample(candidates, 1)[0] wav, sr, pattern_timedict = render_pattern(chosen_fname, input_path) @@ -541,7 +544,7 @@ # If no patterns are found, search for normal audio files candidates = glob.glob('{}/event/{}*.wav'.format(input_path, events_df['sampleid'].loc[n])) chosen_fname = random.sample(candidates, 1)[0] - wav, sr = librosa.load(chosen_fname, sr=SR) + wav, sr = sf.read(chosen_fname) else: chosen_fname = random.sample(candidates, 1)[0] wav, sr, pattern_timedict = render_pattern(chosen_fname, input_path) @@ -685,7 +688,7 @@ logging.debug('{}:New track ebr: {}db'.format(label, 20*np.log10(new_ebr))) if channel_mode == 'separate': - librosa.output.write_wav('{}/{}_event_track.wav'.format(output_path, label), + sf.write('{}/{}_event_track.wav'.format(output_path, label), track_arr/np.max(track_arr), SR) @@ -786,9 +789,9 @@ if channel_mode == 'mono': if append_to_filename: - librosa.output.write_wav('{}/scene_{}.wav'.format(output_path, append_to_filename), scene_arr, SR) + sf.write('{}/scene_{}.wav'.format(output_path, append_to_filename), scene_arr, SR) else: - librosa.output.write_wav('{}/scene.wav'.format(output_path), scene_arr, SR) + sf.write('{}/scene.wav'.format(output_path), scene_arr, SR) # Print timesdict