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: StringModel architecture, e.g. "WaveNet".
config: ModelConfigArchitecture-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
impl NamModel
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self, Error>
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.
Sourcepub fn from_json_str(json: &str) -> Result<Self, Error>
pub fn from_json_str(json: &str) -> Result<Self, Error>
Parse a .nam model from a JSON string already in memory.
Sourcepub fn sample_rate(&self) -> f64
pub fn sample_rate(&self) -> f64
The model’s sample rate, falling back to DEFAULT_SAMPLE_RATE when the
file does not specify one.
Sourcepub fn input_level_dbu(&self) -> Option<f32>
pub fn input_level_dbu(&self) -> Option<f32>
Input calibration level in dBu (analog level at 0 dBFS in), if present.
Sourcepub fn output_level_dbu(&self) -> Option<f32>
pub fn output_level_dbu(&self) -> Option<f32>
Output calibration level in dBu (analog level at 0 dBFS out), if present.