pub struct ChunkStreamer<'a, C: AudioCodec + ?Sized> { /* private fields */ }Expand description
Drives a whole-clip AudioCodec in a chunked / streaming loop: push PCM
chunks to get codes, push code chunks to get PCM. Each chunk is processed
independently (no carried causal state) — this is exactly how moshi/kyutai
drive Mimi today (whole-clip calls on one-frame inputs).
For truly artifact-free, minimal-latency incremental decoding a codec needs
internal state carry (causal-conv ring buffers + transformer KV); see
rlx-qwen3-tts’s StreamingDecoder for the reference design. This wrapper
gives consumers a uniform streaming API over the codecs that only expose
whole-clip encode/decode.
Implementations§
Source§impl<'a, C: AudioCodec + ?Sized> ChunkStreamer<'a, C>
impl<'a, C: AudioCodec + ?Sized> ChunkStreamer<'a, C>
pub fn new(codec: &'a C, num_quantizers: Option<usize>) -> Self
Sourcepub fn with_bitrate(codec: &'a C, target_bps: f32) -> Self
pub fn with_bitrate(codec: &'a C, target_bps: f32) -> Self
Pick the quantizer count from a target bitrate (bits/sec).
Sourcepub fn encode_chunk(&mut self, pcm: &[f32]) -> Result<RvqCodes>
pub fn encode_chunk(&mut self, pcm: &[f32]) -> Result<RvqCodes>
Encode the next PCM chunk to codes.
Sourcepub fn decode_chunk(&mut self, codes: &RvqCodes) -> Result<Vec<f32>>
pub fn decode_chunk(&mut self, codes: &RvqCodes) -> Result<Vec<f32>>
Decode the next code chunk to PCM.
pub fn frames_emitted(&self) -> usize
pub fn samples_emitted(&self) -> usize
pub fn reset(&mut self)
Auto Trait Implementations§
impl<'a, C> Freeze for ChunkStreamer<'a, C>where
C: ?Sized,
impl<'a, C> RefUnwindSafe for ChunkStreamer<'a, C>where
C: RefUnwindSafe + ?Sized,
impl<'a, C> Send for ChunkStreamer<'a, C>
impl<'a, C> Sync for ChunkStreamer<'a, C>
impl<'a, C> Unpin for ChunkStreamer<'a, C>where
C: ?Sized,
impl<'a, C> UnsafeUnpin for ChunkStreamer<'a, C>where
C: ?Sized,
impl<'a, C> UnwindSafe for ChunkStreamer<'a, C>where
C: RefUnwindSafe + ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more