Skip to content

Add torchcodec mock with wav loading and saving #3986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/torchcodec/decoders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import test.torchaudio_unittest.common_utils.wav_utils as wav_utils

class AudioDecoder:
def __init__(self, uri):
self.uri = uri

def get_all_samples(self):
return wav_utils.load_wav(self.uri)


class AudioEncoder:
def __init__(self, data, sample_rate):
self.data = data
self.sample_rate = sample_rate

def to_file(self, uri, bit_rate=None):
return wav_utils.save_wav(uri, self.data, self.sample_rate)
10 changes: 10 additions & 0 deletions test/torchcodec/encoders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import torchaudio_unittest.common_utils.wav_utils as wav_utils

class AudioEncoder:
def __init__(self, data, sample_rate):
print("BEING CALLED")
self.data = data
self.sample_rate = sample_rate

def to_file(self, uri, bit_rate=None):
return wav_utils.save_wav(uri, self.data, self.sample_rate)
Loading