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 argparse | |
import math | |
import os | |
from multiprocessing import Pool, cpu_count | |
import numpy as np | |
import pandas as pd | |
import tensorflow as tf | |
from tqdm import tqdm |
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 pandas as pd | |
import tensorflow as tf | |
AUTOTUNE = tf.data.experimental.AUTOTUNE | |
def get_dataset(df): | |
file_path_ds = tf.data.Dataset.from_tensor_slices(df.file_path) | |
label_ds = tf.data.Dataset.from_tensor_slices(df.label) | |
return tf.data.Dataset.zip((file_path_ds, label_ds)) |
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
# mel spectrum constants. | |
_MEL_BREAK_FREQUENCY_HERTZ = 700.0 | |
_MEL_HIGH_FREQUENCY_Q = 1127.0 | |
def mel_to_hertz(mel_values): | |
"""Converts frequencies in `mel_values` from the mel scale to linear scale.""" | |
return _MEL_BREAK_FREQUENCY_HERTZ * ( | |
np.exp(np.array(mel_values) / _MEL_HIGH_FREQUENCY_Q) - 1.0) |