torchaudio.info¶
- torchaudio.info(uri: Union[BinaryIO, str, PathLike], format: Optional[str] = None, buffer_size: int = 4096, backend: Optional[str] = None) AudioMetaData ¶
Get signal information of an audio file.
Note
When the input type is file-like object, this function cannot get the correct length (
num_samples
) for certain formats, such asvorbis
. In this case, the value ofnum_samples
is0
.- Parameters:
uri (path-like object or file-like object) –
Source of audio data. The following types are accepted:
path-like
: File path or URL.file-like
: Object withread(size: int) -> bytes
method, which returns byte string of at mostsize
length.
format (str or None, optional) – If not
None
, interpreted as hint that may allow backend to override the detected format. (Default:None
)buffer_size (int, optional) – Size of buffer to use when processing file-like objects, in bytes. (Default:
4096
)backend (str or None, optional) –
I/O backend to use. If
None
, function selects backend given input and available backends. Otherwise, must be one of ["ffmpeg"
,"sox"
,"soundfile"
], with the corresponding backend available. (Default:None
)See also
- Returns:
AudioMetaData
- Tutorials using
info
: - Audio I/O
Support Structure¶
AudioMetaData¶
- class torchaudio.AudioMetaData[source]¶
Return type of
torchaudio.info
function.- Variables:
sample_rate (int) – Sample rate
num_frames (int) – The number of frames
num_channels (int) – The number of channels
bits_per_sample (int) – The number of bits per sample. This is 0 for lossy formats, or when it cannot be accurately inferred.
encoding (str) –
Audio encoding The values encoding can take are one of the following:
PCM_S
: Signed integer linear PCMPCM_U
: Unsigned integer linear PCMPCM_F
: Floating point linear PCMFLAC
: Flac, Free Lossless Audio CodecULAW
: Mu-lawALAW
: A-lawMP3
: MP3, MPEG-1 Audio Layer IIIVORBIS
: OGG VorbisAMR_WB
: Adaptive Multi-Rate WidebandAMR_NB
: Adaptive Multi-Rate NarrowbandOPUS
: OpusHTK
: Single channel 16-bit PCMUNKNOWN
: None of above
- Tutorials using
AudioMetaData
: - Audio I/O