def _generate_data(): """Generate data examples.""" wav_file = fake_data_utils.get_random_wav_c1(duration=1, sample=22050) filepath = os.path.join(_output_dir(), "music_speech", "speech_wav", "{}.wav".format("test")) dirname = os.path.dirname(filepath) if not tf.io.gfile.exists(dirname): tf.io.gfile.makedirs(dirname) tf.io.gfile.copy(wav_file, filepath, overwrite=True)
def _generate_data(): """Generate data examples.""" for _ in range(NUMBER_OF_EXAMPLES): wav_file = fake_data_utils.get_random_wav_c1(duration=6, sample=8000) filename = _get_file_name() filepath = os.path.join(_output_dir(), "waves_yesno", "{}.wav".format(filename)) dirname = os.path.dirname(filepath) if not tf.io.gfile.exists(dirname): tf.io.gfile.makedirs(dirname) tf.io.gfile.copy(wav_file, filepath, overwrite=True)
def _generate_data(): """Generate data examples.""" # pylint: disable=protected-access labels = tfds.features.ClassLabel(names=gtzan._CLASS_LABELS).names # pytype: disable=module-attr # pylint: enable=protected-access wav_file = fake_data_utils.get_random_wav_c1(duration=30, sample=22050) # .wav file has name in the format of <genre>.<number>.wav label = random.choice(labels) random_number_for_filename = random.randint(0, 99) filename = "{}.{:05d}".format(label, random_number_for_filename) filepath = os.path.join(_output_dir(), "genres", label, "{}.wav".format(filename)) dirname = os.path.dirname(filepath) if not tf.io.gfile.exists(dirname): tf.io.gfile.makedirs(dirname) tf.io.gfile.copy(wav_file, filepath, overwrite=True)
def _make_wav_file(filepath: str): wav_file = fake_data_utils.get_random_wav_c1(duration=2, sample=16000) dirname = os.path.dirname(filepath) if not tf.io.gfile.exists(dirname): tf.io.gfile.makedirs(dirname) tf.io.gfile.copy(wav_file, filepath, overwrite=True)