Skip to content

am1tyadav/teal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teal - Audio Processing Layers for TensorFlow

Create TensorFlow layers and models for audio preprocessing and audio data augmentation:

✔️ No dependency other than TensorFlow

✔️ Can utilize GPU

✔️ Online preprocessing and data augmentation

✔️ Deploy preprocessing logic in production with the saved model

Teal is in very early stage and a lot of work is to be done. Please feel free to reach out if you'd like to help out!! 😄

Getting Started

Install would be using pip:

pip install --user git+https://github.com/am1tyadav/teal.git

Example: Log Mel Spectrogram Model

import tensorflow as tf
import teal

NUM_SAMPLES = 44100
SAMPLE_RATE = 22050
N_FFT = 2048
HOP_LEN = 512
N_MELS = 64

log_mel_model = tf.keras.models.Sequential([
    tf.keras.layers.Input(shape=(NUM_SAMPLES,)),
    teal.AudioToMelSpectrogram(SAMPLE_RATE, N_FFT, HOP_LEN, N_MELS),
    teal.PowerToDb()
])

# Save it as a Keras model or TF saved model
log_mel_model.save("log_mel.h5")

Example: Audio Data Augmentation Model

import tensorflow as tf
import teal

NUM_SAMPLES = 44100

audio_augmentation_model = tf.keras.models.Sequential([
    tf.keras.layers.Input(shape=(NUM_SAMPLES,)),
    teal.InversePolarity(0.5),
    teal.RandomNoise(0.2),
    teal.RandomGain(0.5)
])

Example: Audio Classification with TensorFlow and Teal

Audio Classification with TensorFlow and Teal

Open In Colab

Layers

Transformation Layers

  • AudioToSTFT
  • AudioToSpectrogram
  • AudioToMelSpectrogram
  • STFTToSpecAndPhase
  • STFTToSpectrogram
  • STFTToPhase
  • SpectrogramToMelSpec
  • PowerToDb
  • DbToPower
  • NormalizeAudio
  • NormalizeSpectrum

Data Augmentation Layers

  • InversePolarity
  • NoiseBank
  • RandomGain
  • RandomNoise
  • PitchShift