torchaudio.functional.apply_codec¶
- torchaudio.functional.apply_codec(waveform: Tensor, sample_rate: int, format: str, channels_first: bool = True, compression: Optional[float] = None, encoding: Optional[str] = None, bits_per_sample: Optional[int] = None) Tensor [source]¶
已弃用:应用编解码器作为一种增强形式。
- 参数:
waveform (Tensor) – 音频数据。必须是二维的。另请参阅
`channels_first`
。sample_rate (int) – 音频波形的采样率。
format (str) – 文件格式。
channels_first (bool, optional) – 如果为 True,则输入和输出 Tensor 都具有维度 (channel, time)。否则,它们具有维度 (time, channel)。
compression (float 或 None, optional) – 用于 WAV 以外的格式。有关更多详细信息,请参阅
torchaudio.backend.sox_io_backend.save()
。encoding (str 或 None, optional) – 更改支持格式的编码。有关更多详细信息,请参阅
torchaudio.backend.sox_io_backend.save()
。bits_per_sample (int 或 None, optional) – 更改支持格式的位深度。有关更多详细信息,请参阅
torchaudio.backend.sox_io_backend.save()
。
- 返回:
结果 Tensor。如果
channels_first=True
,则它具有 (channel, time) 否则为 (time, channel)。- 返回类型:
Tensor
警告
此功能已弃用。请迁移到
torchaudio.io.AudioEffector
。