pub struct NeuCodecDecoder { /* private fields */ }Expand description
NeuCodec decoder: converts speech token IDs to a 24 kHz audio waveform.
§Setup
Set NEUTTS_DECODER_PATH to neucodec_decoder.safetensors, then:
ⓘ
let dec = NeuCodecDecoder::new()?;
let audio = dec.decode(&codes)?;§Backend selection
When built with --features wgpu, the decoder automatically selects the
best available backend on the first call to [decode] (lazy init):
| Priority | Backend | When used |
|---|---|---|
| 1 | Burn wgpu (GPU) | Metal / Vulkan / DX12 adapter found |
| 2 | Burn NdArray (CPU) | No GPU adapter available |
| 3 | Raw ndarray (CPU) | Burn init failed entirely |
The Burn backend is initialised eagerly at from_file
time so the GPU upload cost is part of model loading, not synthesis latency.
Implementations§
Source§impl NeuCodecDecoder
impl NeuCodecDecoder
Sourcepub fn new() -> Result<NeuCodecDecoder, Error>
pub fn new() -> Result<NeuCodecDecoder, Error>
Load from NEUTTS_DECODER_PATH.
Sourcepub fn from_file(path: &Path) -> Result<NeuCodecDecoder, Error>
pub fn from_file(path: &Path) -> Result<NeuCodecDecoder, Error>
Load from an explicit file path.
Sourcepub fn decode(&self, codes: &[i32]) -> Result<Vec<f32>, Error>
pub fn decode(&self, codes: &[i32]) -> Result<Vec<f32>, Error>
Decode speech token IDs to a 24 kHz audio waveform.
codes— integer token IDs in0..=65535(NeuCodec FSQ range). Out-of-range values are rejected with an error rather than silently producing garbage digits from the FSQ decomposition.- returns —
Vec<f32>ofcodes.len() × hop_lengthsamples.
Sourcepub fn backend_name(&self) -> &'static str
pub fn backend_name(&self) -> &'static str
Name of the active inference backend.
Sourcepub fn load(path: &Path) -> Result<NeuCodecDecoder, Error>
pub fn load(path: &Path) -> Result<NeuCodecDecoder, Error>
Alias for from_file — load from an explicit path.
Sourcepub fn weights_path(&self) -> &Path
pub fn weights_path(&self) -> &Path
Path from which the decoder was loaded.
Sourcepub fn hop_length(&self) -> usize
pub fn hop_length(&self) -> usize
Detected hop_length (audio samples per speech token).
Auto Trait Implementations§
impl Freeze for NeuCodecDecoder
impl !RefUnwindSafe for NeuCodecDecoder
impl Send for NeuCodecDecoder
impl Sync for NeuCodecDecoder
impl Unpin for NeuCodecDecoder
impl UnsafeUnpin for NeuCodecDecoder
impl !UnwindSafe for NeuCodecDecoder
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
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