Skip to content

Instantly share code, notes, and snippets.

@ketanhdoshi
Last active November 12, 2021 18:20
Show Gist options
  • Save ketanhdoshi/9de725d230d6602aa5742f1f78c03c9b to your computer and use it in GitHub Desktop.
Save ketanhdoshi/9de725d230d6602aa5742f1f78c03c9b to your computer and use it in GitHub Desktop.
Audio Util
import math, random
import torch
import torchaudio
from torchaudio import transforms
from IPython.display import Audio
class AudioUtil():
# ----------------------------
# Load an audio file. Return the signal as a tensor and the sample rate
# ----------------------------
@staticmethod
def open(audio_file):
sig, sr = torchaudio.load(audio_file)
return (sig, sr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment