Skip to main content

NamModel

Struct NamModel 

Source
pub struct NamModel {
    pub version: String,
    pub architecture: String,
    pub config: ModelConfig,
    pub weights: Vec<f32>,
    pub sample_rate: Option<f64>,
    pub metadata: Option<Value>,
}
Expand description

A parsed .nam model file.

This is the file representation — the raw config + flat weight blob. To run inference, build a crate::WaveNet from it.

Fields§

§version: String

.nam format version string (e.g. "0.5.4").

§architecture: String

Model architecture, e.g. "WaveNet".

§config: ModelConfig

Architecture-specific configuration (dispatched on Self::architecture).

§weights: Vec<f32>

Flat weight blob. The final element is head_scale (see NAM export_weights). Stored as f32 to match NAM Core’s inference precision.

§sample_rate: Option<f64>

Training sample rate. Absent in older files; see Self::sample_rate.

§metadata: Option<Value>

Opaque training/gear metadata. Not used for inference.

Implementations§

Source§

impl NamModel

Source

pub fn from_file(path: impl AsRef<Path>) -> Result<Self, Error>

Read and parse a .nam model from a file on disk.

Convenience over std::fs::read_to_string + Self::from_json_str. Returns Error::Io if the file can’t be read, or Error::Json if its contents aren’t valid .nam JSON.

Source

pub fn from_json_str(json: &str) -> Result<Self, Error>

Parse a .nam model from a JSON string already in memory.

Source

pub fn sample_rate(&self) -> f64

The model’s sample rate, falling back to DEFAULT_SAMPLE_RATE when the file does not specify one.

Source

pub fn loudness(&self) -> Option<f32>

Output loudness in LUFS, if the file records it.

Source

pub fn input_level_dbu(&self) -> Option<f32>

Input calibration level in dBu (analog level at 0 dBFS in), if present.

Source

pub fn output_level_dbu(&self) -> Option<f32>

Output calibration level in dBu (analog level at 0 dBFS out), if present.

Trait Implementations§

Source§

impl Clone for NamModel

Source§

fn clone(&self) -> NamModel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NamModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for NamModel

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,