Skip to main content

MimiCodec

Struct MimiCodec 

Source
pub struct MimiCodec { /* private fields */ }

Implementations§

Source§

impl MimiCodec

Source

pub fn open(model_dir: impl AsRef<Path>) -> Result<MimiCodec, Error>

Source

pub fn open_on( model_dir: impl AsRef<Path>, device: Device, ) -> Result<MimiCodec, Error>

Source

pub fn open_on_with_moshi( model_dir: impl AsRef<Path>, _moshi_dir: Option<&Path>, device: Device, _mimi_codebooks: Option<usize>, ) -> Result<MimiCodec, Error>

Source

pub fn config(&self) -> &MimiConfig

Source

pub fn model_dir(&self) -> &Path

Source

pub fn device(&self) -> Device

Source

pub fn encode_pcm( &self, pcm: &[f32], num_quantizers: Option<usize>, ) -> Result<MimiCodes, Error>

Encode mono PCM @ SAMPLE_RATE.

Source

pub fn decode_codes(&self, codes: &MimiCodes) -> Result<Vec<f32>, Error>

Decode codec frames → mono PCM @ SAMPLE_RATE.

Source

pub fn encode_wav( &self, wav: impl AsRef<Path>, num_quantizers: Option<usize>, ) -> Result<MimiCodes, Error>

Source

pub fn decode_wav( &self, codes: &MimiCodes, out: impl AsRef<Path>, trim_to_samples: Option<usize>, ) -> Result<(), Error>

Source

pub fn roundtrip_pcm( &self, pcm: &[f32], num_quantizers: Option<usize>, ) -> Result<(MimiCodes, Vec<f32>, RoundtripStats), Error>

Source

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).

Source§

fn info(&self) -> CodecInfo

Static metadata (rate, framing, codebooks).
Source§

fn device(&self) -> Device

Backend this codec executes on.
Source§

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>

Decode RVQ codes back to mono PCM at CodecInfo::sample_rate.
Source§

fn sample_rate(&self) -> u32

Convenience: the codec sample rate.
Source§

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>

Encode PCM that arrives at input_rate, resampling to the codec rate first (shared linear resampler).
Source§

fn decode_codes_resampled( &self, codes: &RvqCodes, output_rate: u32, ) -> Result<Vec<f32>, Error>

Decode then resample the waveform to output_rate.
Source§

fn roundtrip_pcm( &self, pcm: &[f32], num_quantizers: Option<usize>, ) -> Result<(RvqCodes, Vec<f32>), Error>

Encode then decode, returning both the codes and the reconstruction.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more