Files
buzz/crates/buzz-voice/src/pocket_models.rs
Tyler 61ba9dfaa0 refactor(voice): extract reusable Pocket primitives + Pocket voice settings (relands #2467 + #3208) (#3910)
Relands **#2467** (extract `buzz-voice` crate) and **#3208** (Pocket
voice settings) onto main, after #3266 and #3180 merged.

## Why a fresh PR
The repo is squash-only with delete-branch-on-merge. Squashing #3266
deleted `jtennant/pocket-tts-2026-04`, which was #2467's base — GitHub
auto-closed #2467 and it cannot be reopened. Squash merges also sever
ancestry, so GitHub's natural merge-base reports phantom conflicts for
the whole remaining stack.

## Content provenance
- Byte-identical to the blessed `jt/buzz-voice-refactor` branch
(`93029c577`, tree `6729e0eff` — reviewed by Dawn (#2467) and Max
(#3208) at exact heads) **except** the three files where #3180 and #3208
genuinely interact.
- Three-file resolution (union of both sides):
- `huddle/mod.rs` — #3180's pipeline re-exports + #3208's
`agent_tts_routing` imports.
- `huddle/state.rs` — `reset_preserving_generation` preserves both
`huddle_generation` (#3180) and `tts_enabled` (#3208); test sets merged
into one `tests` module.
- `desktop/src/testing/e2eBridge.ts` — both switch arms kept; no
duplicate case labels.

## Verification at cf32dacd7
- `cargo test` (desktop/src-tauri, pinned 1.95.0): **2047 + 3 pass / 0
fail** (14 ignored: 8 keychain, 4 real_relay, 2 flag-gated)
- `cargo clippy --all-targets -- -D warnings`: clean; `cargo fmt
--check`: clean
- `cargo check --workspace` (root, includes new `buzz-voice` member):
clean; `cargo test -p buzz-voice`: 5/0
- `pnpm test`: **3885 / 0**; `tsc --noEmit`: clean; lint: clean

The 3180×3208 interaction resolution is getting an independent team
re-review before merge.

Buzz channel: buzz-desktop-voice `fd5fb402-b651-4238-89b1-bb3e2fa4dc96`,
thread `b4798ecc`.

Signed-off-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz>
Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz>
2026-07-31 09:41:09 -04:00

138 lines
4.5 KiB
Rust

//! Immutable capabilities for Buzz Desktop's April Pocket TTS bundle.
/// Pinned upstream export repository.
pub const APRIL_MODEL_ID: &str = "KevinAHM/pocket-tts-onnx";
/// Pinned revision containing the `english_2026-04` bundle.
pub const APRIL_MODEL_REVISION: &str = "58a6d00cf13d239b6748cb0769f35c580a8f606c";
/// Language bundle selected from the pinned export.
pub const APRIL_BUNDLE_ID: &str = "english_2026-04";
/// Maximum input size declared by the April bundle.
pub const APRIL_MAX_TOKEN_PER_CHUNK: usize = 50;
/// One immutable artifact required by the April INT8 runtime.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PocketModelArtifact {
pub filename: &'static str,
pub sha256: &'static str,
pub size_bytes: u64,
pub quantized: bool,
}
/// Capabilities of Buzz Desktop's sole Pocket model.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PocketModelInfo {
/// Language bundle selected from the pinned export.
pub bundle_id: &'static str,
/// Upstream model repository.
pub source_model_id: &'static str,
/// Pinned upstream model revision.
pub revision: &'static str,
/// PCM output sample rate.
pub sample_rate: u32,
/// Maximum input size declared by the bundle.
pub max_token_per_chunk: usize,
/// Immutable files required by the runtime.
pub artifacts: &'static [PocketModelArtifact],
/// Components quantized in the selected bundle.
pub quantized_components: &'static [&'static str],
}
const INT8_ARTIFACTS: [PocketModelArtifact; 8] = [
PocketModelArtifact {
filename: "bundle.json",
sha256: "bab643150f437f37df080a710520ff39ed9ebd9a339f8ebdc739f7eddfc28b3f",
size_bytes: 24_381,
quantized: false,
},
PocketModelArtifact {
filename: "bos_before_voice.npy",
sha256: "f46edf4f7007b7ba4ea58831f49d003e59e167b4641c44bb3addfe9231a780b1",
size_bytes: 4_224,
quantized: false,
},
PocketModelArtifact {
filename: "tokenizer.model",
sha256: "d461765ae179566678c93091c5fa6f2984c31bbe990bf1aa62d92c64d91bc3f6",
size_bytes: 59_339,
quantized: false,
},
PocketModelArtifact {
filename: "flow_lm_main_int8.onnx",
sha256: "f9bd8106b79a0192c1c43399ab938fb24900a95c1c599870d75a884e99000116",
size_bytes: 76_341_079,
quantized: true,
},
PocketModelArtifact {
filename: "flow_lm_flow_int8.onnx",
sha256: "3dd781ee5abee9e195320bf0106bebd6372a852b3b36352524ee78b40554635d",
size_bytes: 9_962_530,
quantized: true,
},
PocketModelArtifact {
filename: "mimi_decoder_int8.onnx",
sha256: "3630450a3297a101792a6ac66619ebc70ab916b265e6220c2afaef8b1673f925",
size_bytes: 22_684_077,
quantized: true,
},
PocketModelArtifact {
filename: "mimi_encoder.onnx",
sha256: "853e2ca623b8782d94c3745ec6133bfdff7ce33d9b11128bd29ea03f28d76e3d",
size_bytes: 39_768_446,
quantized: false,
},
PocketModelArtifact {
filename: "text_conditioner.onnx",
sha256: "4ecee995fb69f85c7a7493d11f7b5ee15d9950facc7ab3f5c9c49ef1e03847bb",
size_bytes: 16_388_344,
quantized: false,
},
];
const INT8_COMPONENTS: [&str; 3] = ["flow_lm_main", "flow_lm_flow", "mimi_decoder"];
/// Return immutable metadata for Buzz Desktop's April INT8 model.
pub const fn april_model_info() -> PocketModelInfo {
PocketModelInfo {
bundle_id: APRIL_BUNDLE_ID,
source_model_id: APRIL_MODEL_ID,
revision: APRIL_MODEL_REVISION,
sample_rate: 24_000,
max_token_per_chunk: APRIL_MAX_TOKEN_PER_CHUNK,
artifacts: &INT8_ARTIFACTS,
quantized_components: &INT8_COMPONENTS,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn metadata_matches_pinned_int8_layout() {
let info = april_model_info();
assert_eq!(info.artifacts.len(), 8);
assert_eq!(
info.quantized_components,
["flow_lm_main", "flow_lm_flow", "mimi_decoder"]
);
assert_eq!(
info.artifacts
.iter()
.map(|artifact| artifact.size_bytes)
.sum::<u64>(),
165_232_420
);
assert!(info
.artifacts
.iter()
.any(|artifact| { artifact.filename == "mimi_encoder.onnx" && !artifact.quantized }));
assert!(!info
.artifacts
.iter()
.any(|artifact| artifact.filename == "mimi_encoder_int8.onnx"));
}
}