Views
No views yet
$ pip install git+https://github.com/facebookresearch/dacvae1from dacvae import DACVAE
2import torchaudio
3
4
5model = DACVAE.load("facebook/dacvae-watermarked")
6wav, sample_rate = torchaudio.load("<path to audio file>")
7# Resample to expected sample rate
8resampled = torchaudio.functional.resample(wav, sample_rate, model.sample_rate)
9# Convert stero to mono (if applicable)
10resampled = resampled.mean(dim=0, keepdim=True)
11# Expected shape is batch x 1 x samples
12model_input = resampled.unsqueeze(0)
13encoded = model.encode(model_input)
14# `decoded` shape is `batch x 1 x samples`
15decoded = model.decode(encoded)