Commit 9f5fa84b authored by Jeff Hwang's avatar Jeff Hwang Committed by Facebook GitHub Bot
Browse files

Revise VGGish inference pipeline test (#3544)

Summary:
Pull Request resolved: https://github.com/pytorch/audio/pull/3544

Revises VGGish inference pipeline test to support internal testing.

Reviewed By: mthrok

Differential Revision: D48058409

fbshipit-source-id: 045140a0e9d50128d32ef6510bdb2f642a365c83
parent eab8aa74
import unittest
import torchaudio import torchaudio
from torchaudio.prototype.pipelines import VGGISH from torchaudio.prototype.pipelines import VGGISH
def test_vggish(): class VGGishPipelineTest(unittest.TestCase):
input_sr = VGGISH.sample_rate def test_vggish(self):
input_proc = VGGISH.get_input_processor() input_sr = VGGISH.sample_rate
model = VGGISH.get_model() input_proc = VGGISH.get_input_processor()
path = torchaudio.utils.download_asset("test-assets/Chopin_Ballade_-1_In_G_Minor,_Op._23_excerpt.mp3") model = VGGISH.get_model()
waveform, sr = torchaudio.load(path, backend="ffmpeg") path = torchaudio.utils.download_asset("test-assets/Chopin_Ballade_-1_In_G_Minor,_Op._23_excerpt.mp3")
waveform = waveform.mean(axis=0) waveform, sr = torchaudio.load(path, backend="ffmpeg")
waveform = torchaudio.functional.resample(waveform, sr, input_sr) waveform = waveform.mean(axis=0)
batch = input_proc(waveform) waveform = torchaudio.functional.resample(waveform, sr, input_sr)
assert batch.shape == (62, 1, 96, 64) batch = input_proc(waveform)
output = model(batch) assert batch.shape == (62, 1, 96, 64)
assert output.shape == (62, 128) output = model(batch)
assert output.shape == (62, 128)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment