Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import numpy as np
import librosa
import pandas as pd
import numpy.random as rnd
import pathlib
import tqdm
dataset_folder = pathlib.Path('noise_data')
dataset_folder.mkdir(parents=True, exist_ok=True)
num_examples = 100
time_duration = 10
fs = 48000
num_samples = int(fs*time_duration)
prettyProgressBar = tqdm.tqdm(range(num_examples))
for i in prettyProgressBar:
x = rnd.randn(num_samples)
x /= np.maximum(np.max(x), -np.min(x))
x *= rnd.rand()
filepath = dataset_folder / f'noise_{i}.wav'
librosa.output.write_wav(filepath, x, fs, norm=False)
file_list = list(dataset_folder.glob('*.wav'))
example_type = num_examples * ['eval']
scene_label = num_examples * ['not_scene']
city = num_examples * ['no_city']
identifier = num_examples * ['rand']
source_label = num_examples * ['z']
dict_data = {'filename': file_list,
'example_type': example_type,
'scene_label': scene_label,
'city': city,
'identifier': identifier,
'source_label': source_label}
df = pd.DataFrame(dict_data)
df.to_csv('noise_meta.csv', index=False, sep='\t')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment