pub struct MimiCodec { /* private fields */ }Implementations§
Source§impl MimiCodec
impl MimiCodec
pub fn open(model_dir: impl AsRef<Path>) -> Result<MimiCodec, Error>
pub fn open_on( model_dir: impl AsRef<Path>, device: Device, ) -> Result<MimiCodec, Error>
pub fn open_on_with_moshi( model_dir: impl AsRef<Path>, _moshi_dir: Option<&Path>, device: Device, _mimi_codebooks: Option<usize>, ) -> Result<MimiCodec, Error>
pub fn config(&self) -> &MimiConfig
pub fn model_dir(&self) -> &Path
pub fn device(&self) -> Device
Sourcepub fn encode_pcm(
&self,
pcm: &[f32],
num_quantizers: Option<usize>,
) -> Result<MimiCodes, Error>
pub fn encode_pcm( &self, pcm: &[f32], num_quantizers: Option<usize>, ) -> Result<MimiCodes, Error>
Encode mono PCM @ SAMPLE_RATE.
Sourcepub fn decode_codes(&self, codes: &MimiCodes) -> Result<Vec<f32>, Error>
pub fn decode_codes(&self, codes: &MimiCodes) -> Result<Vec<f32>, Error>
Decode codec frames → mono PCM @ SAMPLE_RATE.
pub fn encode_wav( &self, wav: impl AsRef<Path>, num_quantizers: Option<usize>, ) -> Result<MimiCodes, Error>
pub fn decode_wav( &self, codes: &MimiCodes, out: impl AsRef<Path>, trim_to_samples: Option<usize>, ) -> Result<(), Error>
pub fn roundtrip_pcm( &self, pcm: &[f32], num_quantizers: Option<usize>, ) -> Result<(MimiCodes, Vec<f32>, RoundtripStats), Error>
pub fn roundtrip_wav( &self, in_wav: impl AsRef<Path>, out_wav: impl AsRef<Path>, num_quantizers: Option<usize>, ) -> Result<MimiCodes, Error>
Trait Implementations§
Source§impl AudioCodec for MimiCodec
Unified rlx_core::AudioCodec view so TTS/ASR consumers can use Mimi
interchangeably with other codecs (bitrate control + resampling for free).
impl AudioCodec for MimiCodec
Unified rlx_core::AudioCodec view so TTS/ASR consumers can use Mimi
interchangeably with other codecs (bitrate control + resampling for free).
Source§fn encode_pcm(
&self,
pcm: &[f32],
num_quantizers: Option<usize>,
) -> Result<RvqCodes, Error>
fn encode_pcm( &self, pcm: &[f32], num_quantizers: Option<usize>, ) -> Result<RvqCodes, Error>
Encode mono PCM (at
CodecInfo::sample_rate) to RVQ codes. None uses
the codec’s full quantizer count.Source§fn decode_codes(&self, codes: &RvqCodes) -> Result<Vec<f32>, Error>
fn decode_codes(&self, codes: &RvqCodes) -> Result<Vec<f32>, Error>
Decode RVQ codes back to mono PCM at
CodecInfo::sample_rate.Source§fn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Convenience: the codec sample rate.
Source§fn encode_pcm_bitrate(
&self,
pcm: &[f32],
target_bps: f32,
) -> Result<RvqCodes, Error>
fn encode_pcm_bitrate( &self, pcm: &[f32], target_bps: f32, ) -> Result<RvqCodes, Error>
Encode at a target bitrate (bits/sec) rather than an explicit quantizer
count — the codec maps the bitrate to codebooks via
CodecInfo.Source§fn encode_pcm_resampled(
&self,
pcm: &[f32],
input_rate: u32,
num_quantizers: Option<usize>,
) -> Result<RvqCodes, Error>
fn encode_pcm_resampled( &self, pcm: &[f32], input_rate: u32, num_quantizers: Option<usize>, ) -> Result<RvqCodes, Error>
Encode PCM that arrives at
input_rate, resampling to the codec rate
first (shared linear resampler).Auto Trait Implementations§
impl !Freeze for MimiCodec
impl !RefUnwindSafe for MimiCodec
impl !Sync for MimiCodec
impl !UnwindSafe for MimiCodec
impl Send for MimiCodec
impl Unpin for MimiCodec
impl UnsafeUnpin for MimiCodec
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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