-
Notifications
You must be signed in to change notification settings - Fork 42
Add Docs for AudioEncoder #717
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
base: main
Are you sure you want to change the base?
Conversation
docs/source/conf.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in this file, as well as the files renaming, are meant to separate our "tutorials" page into 2 separate sections: one for decoding, one for encoding.
@@ -16,8 +26,11 @@ def __init__(self, samples: Tensor, *, sample_rate: int): | |||
raise ValueError( | |||
f"Expected samples to be a Tensor, got {type(samples) = }." | |||
) | |||
if samples.ndim == 1: | |||
# make it 2D and assume 1 channel | |||
samples = samples[None, :] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by, I think this makes sense, i.e. if the input tensor is 1D we assume it's 1 channel instead of raising an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that the most idomatic way to do that? There's also unsqueeze, view or reshape. Minor, but I'm surprised at how this works.
uses the version of FFmpeg you already have installed. FFmpeg is a mature | ||
library with broad coverage available on most systems. It is, however, not | ||
easy to use. TorchCodec abstracts FFmpeg's complexity to ensure it is used | ||
* Relying on [FFmpeg](https://www.ffmpeg.org/) to do the decoding / encoding. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I prefer "x and y" as opposed to "x / y" in prose.
order = [ | ||
"audio_encoding.py", | ||
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment explaining that we have two top-level galleries, and for that reason, we need to figure out which gallery we're using (decoding versus encoding)? I was real confused until I concluded that must be what's going on.
Moving the examples into decoding and encoding subdirectories makes sense, but I'm curious: will that change the resulting tutorial URL? We already have some pointers to these tutorials floating around blogs and social media. |
|
||
# %% | ||
# We first instantiate an :class:`~torchcodec.encoders.AudioEncoder`. We pass it | ||
# the samples to be encoded. The samples must a 2D tensors of shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "The samples must be a 2D tensors of shape"
This PR adds docstrings and a tutorial for the
AudioEncoder
, plus some minor changes listed in the comments below