pub struct AudioEncoder {
pub config: AudioConfig,
pub audio_token_id: u32,
pub begin_audio_token_id: u32,
}Expand description
Encoder for converting audio data into token sequences.
The AudioEncoder processes audio waveforms and converts them into token
sequences that can be mixed with text tokens in multimodal applications.
§Fields
config- Audio processing configurationaudio_token_id- Token ID (u32) for audio content tokensbegin_audio_token_id- Token ID (u32) for marking the start of audio
Fields§
§config: AudioConfig§audio_token_id: u32§begin_audio_token_id: u32Implementations§
Source§impl AudioEncoder
impl AudioEncoder
Sourcepub fn new(
config: AudioConfig,
audio_token_id: u32,
begin_audio_token_id: u32,
) -> Self
pub fn new( config: AudioConfig, audio_token_id: u32, begin_audio_token_id: u32, ) -> Self
Sourcepub fn encode(&self, audio: Audio) -> Result<AudioEncoding>
pub fn encode(&self, audio: Audio) -> Result<AudioEncoding>
Encodes audio data into a token sequence.
This method processes the audio through resampling, padding, and tokenization to produce a sequence of tokens that represents the audio content.
§Arguments
audio- The audio data to encode
§Returns
An AudioEncoding containing the token sequence and processed audio.
§Errors
Returns an error if audio processing fails.
§Examples
use tekken::audio::{Audio, AudioConfig, AudioSpectrogramConfig, AudioEncoder};
let audio = Audio::from_file("audio.wav")?;
let spectrogram_config = AudioSpectrogramConfig::new(80, 160, 400)?;
let audio_config = AudioConfig::new(16000, 12.5, spectrogram_config, None)?;
let encoder = AudioEncoder::new(audio_config, 1000, 1001);
let encoding = encoder.encode(audio)?;
println!("Audio encoded to {} tokens", encoding.tokens.len());Trait Implementations§
Source§impl Clone for AudioEncoder
impl Clone for AudioEncoder
Source§fn clone(&self) -> AudioEncoder
fn clone(&self) -> AudioEncoder
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 moreAuto Trait Implementations§
impl Freeze for AudioEncoder
impl RefUnwindSafe for AudioEncoder
impl Send for AudioEncoder
impl Sync for AudioEncoder
impl Unpin for AudioEncoder
impl UnwindSafe for AudioEncoder
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