Skip to content

Instantly share code, notes, and snippets.

@gustheman
Created March 8, 2023 15:51
Show Gist options
  • Save gustheman/f576df0bf3f3eb58e07d0f86c980ac74 to your computer and use it in GitHub Desktop.
Save gustheman/f576df0bf3f3eb58e07d0f86c980ac74 to your computer and use it in GitHub Desktop.
Creates a spectrogram based on a waveform
import tensorflow as tf
import tensorflow_io as tfio
tensor = tf.cast(audio_tensor, tf.float32) / 32768.0
spectrogram = tfio.audio.spectrogram(
tensor, nfft=512, window=512, stride=256)
mel_spectrogram= tfio.audio.melscale(
spectrogram, rate=16000, mels=128, fmin=0, fmax=8000)
dbscale_mel_spectrogram= tfio.audio.dbscale(mel_spectrogram, top_db=80)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment