torchaudio.info¶
- torchaudio.info(uri: Union[BinaryIO, str, PathLike], format: Optional[str] = None, buffer_size: int = 4096, backend: Optional[str] = None) AudioMetaData¶
DEPRECATED
Warning
This function has been deprecated. It will be removed from 2.9 release. This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. The decoding and encoding capabilities of PyTorch for both audio and video are being consolidated into TorchCodec. Please see https://github.com/pytorch/audio/issues/3902 for more information.
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_samplesis0.- Args:
- 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) -> bytesmethod, which returns byte string of at mostsizelength.
- 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:
Support Structure¶
AudioMetaData¶
- class torchaudio.AudioMetaData(sample_rate: int, num_frames: int, num_channels: int, bits_per_sample: int, encoding: str)[source]¶
DEPRECATED
Warning
This class is deprecated from version 2.8. It will be removed in the 2.9 release. This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. The decoding and encoding capabilities of PyTorch for both audio and video are being consolidated into TorchCodec. Please see https://github.com/pytorch/audio/issues/3902 for more information.
AudioMetaData()
Return type of
torchaudio.infofunction.- ivar int sample_rate
Sample rate
- ivar int num_frames
The number of frames
- ivar int num_channels
The number of channels
- ivar int bits_per_sample
The number of bits per sample. This is 0 for lossy formats, or when it cannot be accurately inferred.
- ivar str encoding
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: