piper1-rs 0.1.0

Safe Rust bindings to Piper, the TTS library
Documentation
//! JSON models used in deserializing `voices.json`. Deserialize `voices.json` using [`ModelList`].

use std::collections::HashMap;

use serde::{Deserialize, Serialize};

use super::{Language, ModelQuality, SpeakerIdMap};

/// This is the base type one should parse into to deserialize `voices.json`.
pub type ModelList = HashMap<String, ModelDetails>;

/// A single model contained in `voices.json`.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelDetails {
	/// Same as the key for this element in the base type.
	pub key:            String,
	/// The name of the model. Typically, a name for a speaker.
	pub name:           String,
	/// Language details for the model
	pub language:       Language,
	/// The quality of the model.
	pub quality:        ModelQuality,
	/// The number of unique speakers, or in other words, the length of speaker_id_map
	pub num_speakers:   u8,
	/// A map of speaker names to their model level IDs.
	pub speaker_id_map: SpeakerIdMap,
	/// A map of filenames to their details.
	pub files:          HashMap<String, FileDetails>,
	/// Different names for the same model.
	pub aliases:        Vec<String>,
}

/// A file attached to a model.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FileDetails {
	/// The size of the file in bytes.
	pub size_bytes: u32,
	/// The MD5 checksum of the file.
	pub md5_digest: String,
}