pub struct AudioConfig {
pub sampling_rate: usize,
pub frame_rate: f64,
pub audio_encoding_config: AudioSpectrogramConfig,
pub chunk_length_s: Option<f64>,
}Expand description
Configuration for audio processing and tokenization.
This struct contains all parameters needed to process audio files and convert them into token sequences that can be mixed with text tokens.
§Fields
sampling_rate- Target sampling rate in Hz (e.g., 16000)frame_rate- Number of frames per second for the tokenizer modelaudio_encoding_config- Spectrogram generation parameterschunk_length_s- Optional chunk length in seconds for padding
Fields§
§sampling_rate: usize§frame_rate: f64§audio_encoding_config: AudioSpectrogramConfig§chunk_length_s: Option<f64>Implementations§
Source§impl AudioConfig
impl AudioConfig
Sourcepub fn new(
sampling_rate: usize,
frame_rate: f64,
encoding_config: AudioSpectrogramConfig,
chunk_length_s: Option<f64>,
) -> Result<Self>
pub fn new( sampling_rate: usize, frame_rate: f64, encoding_config: AudioSpectrogramConfig, chunk_length_s: Option<f64>, ) -> Result<Self>
Creates a new AudioConfig with validation.
§Arguments
sampling_rate- Target sampling rate in Hz (must be > 0)frame_rate- Number of frames per second (must be > 0)encoding_config- Spectrogram configurationchunk_length_s- Optional chunk length in seconds (must be > 0 if provided)
§Returns
A new AudioConfig instance.
§Errors
Returns an error if any parameter is invalid.
Sourcepub fn chunk_frames(&self) -> Result<usize>
pub fn chunk_frames(&self) -> Result<usize>
Sourcepub fn audio_length_per_tok(&self) -> usize
pub fn audio_length_per_tok(&self) -> usize
Calculates the length of audio (in samples) represented by each token.
This determines the downsampling factor from audio samples to tokens based on the frame rate and spectrogram hop length.
§Returns
Number of audio samples per token.
Trait Implementations§
Source§impl Clone for AudioConfig
impl Clone for AudioConfig
Source§fn clone(&self) -> AudioConfig
fn clone(&self) -> AudioConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AudioConfig
impl Debug for AudioConfig
Source§impl<'de> Deserialize<'de> for AudioConfig
impl<'de> Deserialize<'de> for AudioConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for AudioConfig
impl RefUnwindSafe for AudioConfig
impl Send for AudioConfig
impl Sync for AudioConfig
impl Unpin for AudioConfig
impl UnwindSafe for AudioConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more