The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
feat(speech): the sheet shows each model its own controls, and a sample voice
Jareerb7a1b912d899
diff --git a/src/crates/concat-speech/src/tts.rs b/src/crates/concat-speech/src/tts.rsindex a52db37f..07482430 100644--- a/src/crates/concat-speech/src/tts.rs+++ b/src/crates/concat-speech/src/tts.rs@@ -103,12 +103,12 @@ const KNOWN_MODELS: &[KnownModel] = &[KnownModel {id: crate::chatterbox::BUNDLE_ID,label: "Chatterbox Turbo (studio)",- blurb: "The closest to a studio voice; reads in the selected clip's voice. English, slow, a gigabyte.",+ blurb: "The closest to a studio voice; reads in Pocket's recordings or any sample of your own. English, slow, a gigabyte.",approx_bytes: crate::chatterbox::BUNDLE_BYTES,sha256: "",},KnownModel {- id: "sherpa-onnx-pocket-tts-int8-2026-01-26",+ id: POCKET_ID,label: "Pocket TTS (cloning)",blurb: "Reads in any voice, including one from a clip on the timeline. English.",approx_bytes: 98_336_520,@@ -187,17 +187,29 @@ pub const POCKET_VOICES: &[(i32, &str, Option<&str>)] = &[(POCKET_CLONE, "pocket_clone", None),];-/// The voice that is the selected clip's own.+/// The voice that is a recording of the caller's choosing - a clip on the+/// timeline, a file in the bin - handed over as the request's reference.pub const POCKET_CLONE: i32 = 1099;-/// Chatterbox's voices: only the selected clip's own, since the model has-/// no speakers of its own and ships no recording of anyone's.-pub const CHATTERBOX_VOICES: &[(i32, &str)] = &[(CHATTERBOX_CLONE, "chatterbox_clone")];+/// The Pocket bundle, which is also where the stock recordings live.+pub const POCKET_ID: &str = "sherpa-onnx-pocket-tts-int8-2026-01-26";++/// Chatterbox's voices. The model has no speakers of its own and ships no+/// recording of anyone's under a licence this build may carry, so its+/// stock voices are Pocket's two recordings, read from the Pocket bundle:+/// offered only while that bundle is on disk, and named as Chatterbox's+/// so a voice id still says which family reads it. The third is a+/// recording of the caller's choosing, as Pocket's is.+pub const CHATTERBOX_VOICES: &[(i32, &str, Option<&str>)] = &[+ (2000, "chatterbox_bria", Some("test_wavs/bria.wav")),+ (2001, "chatterbox_loona", Some("test_wavs/loona.wav")),+ (CHATTERBOX_CLONE, "chatterbox_clone", None),+];-/// The selected clip's own voice, read by Chatterbox.+/// A recording of the caller's choosing, read by Chatterbox.pub const CHATTERBOX_CLONE: i32 = 2099;-/// Whether a voice is the selected clip's own, in any family.+/// Whether a voice is a recording of the caller's choosing, in any family.pub fn is_clone(voice: i32) -> bool {voice == POCKET_CLONE || voice == CHATTERBOX_CLONE}@@ -212,7 +224,7 @@ pub fn voice_family(voice: i32) -> Option<Family> {Some(Family::Kokoro)} else if POCKET_VOICES.iter().any(|(id, _, _)| *id == voice) {Some(Family::Pocket)- } else if CHATTERBOX_VOICES.iter().any(|(id, _)| *id == voice) {+ } else if CHATTERBOX_VOICES.iter().any(|(id, _, _)| *id == voice) {Some(Family::Chatterbox)} else {None@@ -234,8 +246,8 @@ fn voice_name(voice: i32) -> Option<&'static str> {.or_else(|| {CHATTERBOX_VOICES.iter()- .find(|(id, _)| *id == voice)- .map(|(_, name)| *name)+ .find(|(id, _, _)| *id == voice)+ .map(|(_, name, _)| *name)})}@@ -362,8 +374,19 @@ pub struct SpeakRequest {pub reference: Option<Reference>,/// What to say.pub text: String,- /// Speaking rate; 1.0 is the voice's natural pace.+ /// Speaking rate; 1.0 is the voice's natural pace. Kokoro and Pocket+ /// honour it; Chatterbox reads at its own.pub speed: f32,+ /// The breath between sentences, as sherpa scales it: 0 runs them+ /// together, 1 is a long pause, 0.2 is the engine's own. Absent is+ /// the engine's own. Kokoro and Pocket.+ #[serde(default)]+ pub pauses: Option<f32>,+ /// Pocket's flow-matching steps: more is a cleaner voice and a longer+ /// wait, 5 is the engine's own. Absent is the engine's own; the other+ /// families have no such dial and ignore it.+ #[serde(default)]+ pub steps: Option<i32>,/// The project folder the WAV should land in.pub project: String,}@@ -449,11 +472,18 @@ impl Speech {name: (*name).to_owned(),family: Family::Pocket,}))- .chain(CHATTERBOX_VOICES.iter().map(|(id, name)| VoiceInfo {- id: *id,- name: (*name).to_owned(),- family: Family::Chatterbox,- }))+ // Chatterbox's stock voices are Pocket's recordings, and are+ // only offered while the bundle holding them is here.+ .chain(+ CHATTERBOX_VOICES+ .iter()+ .filter(|(_, _, file)| file.is_none() || model_downloaded(dirs, POCKET_ID))+ .map(|(id, name, _)| VoiceInfo {+ id: *id,+ name: (*name).to_owned(),+ family: Family::Chatterbox,+ }),+ ).collect(),})}@@ -607,6 +637,14 @@ impl Speech {} else {1.0};+ let defaults = GenerationConfig::default();+ let silence_scale = request+ .pauses+ .filter(|pauses| pauses.is_finite())+ .map_or(defaults.silence_scale, |pauses| pauses.clamp(0.0, 1.0));+ let num_steps = request+ .steps+ .map_or(defaults.num_steps, |steps| steps.clamp(1, 16));let dir = model_dir(dirs, &request.model_id)?;if !model_downloaded(dirs, &request.model_id) {@@ -664,10 +702,18 @@ impl Speech {// Chatterbox is its own loop: the recording in, the samples out,// and the file written here. Sherpa's families go on below.+ // A named voice's recording lives in the Pocket bundle, whichever+ // model reads it; a chosen recording needs no bundle at all.+ let recordings = if is_clone(request.voice) {+ dir.clone()+ } else {+ recordings_dir(dirs)?+ };+#[cfg(feature = "chatterbox")]let tts = match tts {Engine::Chatterbox(chatterbox) => {- let samples = reference_samples(&dir, request)?;+ let samples = reference_samples(&recordings, request)?;let mut progress = progress;let spoken = chatterbox.speak(text, &samples, &cancel, &mut |fraction| {progress(fraction);@@ -694,12 +740,15 @@ impl Speech {Family::Kokoro => GenerationConfig {sid: request.voice,speed,+ silence_scale,..Default::default()},_ => {- let samples = reference_samples(&dir, request)?;+ let samples = reference_samples(&recordings, request)?;GenerationConfig {speed,+ silence_scale,+ num_steps,reference_audio: Some(samples),reference_sample_rate: REFERENCE_RATE as i32,extra: Some(@@ -772,14 +821,28 @@ impl Speech {/// the rate its bundled recordings are in.const REFERENCE_RATE: u32 = 24_000;-/// The recording a Pocket request reads the voice from, as mono samples-/// at [`REFERENCE_RATE`]: one of the bundle's own for a named voice, or-/// the request's reference for the clone, cut to [`REFERENCE_SECONDS`]-/// from where the voice is heard.+/// Where the stock recordings are: the Pocket bundle. An error naming the+/// fix when it is not on disk, since a Chatterbox voice borrowed from it+/// can be asked for without Pocket ever having been downloaded.+fn recordings_dir(dirs: &AppDirs) -> Result<PathBuf, String> {+ if !model_downloaded(dirs, POCKET_ID) {+ return Err(+ "the stock voices are Pocket TTS's recordings - download Pocket TTS in Settings > \+ Speech, or read in a sample voice of your own"+ .to_owned(),+ );+ }+ model_dir(dirs, POCKET_ID)+}++/// The recording a request reads the voice from, as mono samples at+/// [`REFERENCE_RATE`]: one of the stock recordings in `dir` for a named+/// voice, or the request's reference for a chosen one, cut to+/// [`REFERENCE_SECONDS`] from where the voice is heard.fn reference_samples(dir: &Path, request: &SpeakRequest) -> Result<Vec<f32>, String> {let (path, start) = if is_clone(request.voice) {let reference = request.reference.as_ref().ok_or_else(|| {- "no clip to take the voice from - select a clip with a voice in it".to_owned()+ "no recording to take the voice from - pick a sample with a voice in it".to_owned()})?;(PathBuf::from(&reference.path),@@ -792,6 +855,7 @@ fn reference_samples(dir: &Path, request: &SpeakRequest) -> Result<Vec<f32>, Str} else {let file = POCKET_VOICES.iter()+ .chain(CHATTERBOX_VOICES.iter()).find(|(id, _, _)| *id == request.voice).and_then(|(_, _, file)| *file).ok_or_else(|| format!("voice {} has no recording", request.voice))?;@@ -956,11 +1020,15 @@ mod tests {}for (id, name, _) in POCKET_VOICES {assert_eq!(voice_name(*id), Some(*name));- assert!(!CHATTERBOX_VOICES.iter().any(|(other, _)| other == id));+ assert!(!CHATTERBOX_VOICES.iter().any(|(other, _, _)| other == id));}- for (id, name) in CHATTERBOX_VOICES {+ for (id, name, _) in CHATTERBOX_VOICES {assert_eq!(voice_name(*id), Some(*name));+ assert_eq!(voice_family(*id), Some(Family::Chatterbox));}+ // The stock Chatterbox voices are Pocket's recordings by another name.+ assert_eq!(CHATTERBOX_VOICES[0].2, POCKET_VOICES[0].2);+ assert_eq!(CHATTERBOX_VOICES[1].2, POCKET_VOICES[1].2);assert_eq!(voice_name(999), None);for model in KNOWN_MODELS {assert!(known(model.id).is_some());@@ -977,10 +1045,12 @@ mod tests {reference,text: "hello".to_owned(),speed: 1.0,+ pauses: None,+ steps: None,project: String::new(),};let error = reference_samples(&dir, &request(POCKET_CLONE, None)).expect_err("no clip");- assert!(error.contains("select a clip"), "{error}");+ assert!(error.contains("pick a sample"), "{error}");// A recording that is not there names itself.let error = reference_samples(&dir, &request(1000, None)).expect_err("no file");assert!(error.contains("bria.wav"), "{error}");diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.jsonindex de764ec5..8b9a1ba0 100644--- a/src/crates/concat/locales/de.json+++ b/src/crates/concat/locales/de.json@@ -203,7 +203,6 @@"Fade in": "Einblenden","Fade out": "Ausblenden","Fades": "Blenden",- "Faster": "Schneller","Favourites": "Favoriten","Feather": "Weiche Kante","female": "weiblich",@@ -358,7 +357,6 @@"Outline": "Kontur","Output": "Ausgabe","Output · {0}": "Ausgabe · {0}",- "Pace": "Tempo","Paste": "Einfügen","Pause": "Pause","Person": "Person",@@ -449,7 +447,6 @@"Slide Left": "Nach links gleiten","Slide Right": "Nach rechts gleiten","Slide Up": "Nach oben gleiten",- "Slower": "Langsamer","Small": "Klein","Smart brush": "Smart-Pinsel","Smart brush: {0}": "Smart-Pinsel: {0}",diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.jsonindex 079a8cbd..29f341c6 100644--- a/src/crates/concat/locales/en.json+++ b/src/crates/concat/locales/en.json@@ -77,6 +77,7 @@"Analysis": "Analysis","Angle": "Angle","Animation": "Animation",+ "Any voice, from a recording": "Any voice, from a recording","Appearance": "Appearance","Application": "Application","Apply": "Apply",@@ -136,6 +137,7 @@"Browse": "Browse","Brush": "Brush","Build": "Build",+ "Built-in speakers · fast": "Built-in speakers · fast","Bulge / Pinch": "Bulge / Pinch","Bullet": "Bullet","Bypass {0}": "Bypass {0}",@@ -153,6 +155,7 @@"centred": "centred","Change pitch with speed": "Change pitch with speed","Change what this panel shows, or drag it onto another": "Change what this panel shows, or drag it onto another",+ "Chatterbox has no voice of its own. Turn on Use sample voice below, or download Pocket TTS in Settings › Speech to borrow its two recordings.": "Chatterbox has no voice of its own. Turn on Use sample voice below, or download Pocket TTS in Settings › Speech to borrow its two recordings.","Chill": "Chill","Chinese": "Chinese","Chipmunk": "Chipmunk",@@ -310,6 +313,7 @@"Export…": "Export…","Exposure": "Exposure","Exposure is in stops; the rest is a signed percent of the picture as shot, and zero everywhere is the picture as shot. Double-click a label to put it back; the diamond keys the knob at the playhead.": "Exposure is in stops; the rest is a signed percent of the picture as shot, and zero everywhere is the picture as shot. Double-click a label to put it back; the diamond keys the knob at the playhead.",+ "Expression": "Expression","Faces brightened and evened: skin lifted, reds calmed, the balance neutral, the rest of the frame left where it was.": "Faces brightened and evened: skin lifted, reds calmed, the balance neutral, the rest of the frame left where it was.","Fade": "Fade","Fade in": "Fade in",@@ -318,7 +322,6 @@"Fades": "Fades","Fair": "Fair","Falling Dust": "Falling Dust",- "Faster": "Faster","Favourites": "Favourites","Feather": "Feather","Featured": "Featured",@@ -334,6 +337,7 @@"Filters": "Filters","Finalising file": "Finalising file","Finding the subject… {0}%": "Finding the subject… {0}%",+ "Fine": "Fine","Fine specks of dust flicker over the picture, frame to frame.": "Fine specks of dust flicker over the picture, frame to frame.","Fisheye": "Fisheye","Fit the frame to the pane": "Fit the frame to the pane",@@ -417,6 +421,7 @@"Images": "Images","Impact Ring": "Impact Ring","Import": "Import",+ "Import a clip with a voice in it first.": "Import a clip with a voice in it first.","Import a LUT (.cube)": "Import a LUT (.cube)","Import LUT": "Import LUT","Import media": "Import media",@@ -483,6 +488,8 @@"Location": "Location","Lock lane": "Lock lane","Lock track": "Lock track",+ "long": "long",+ "longer": "longer","Loop": "Loop","Low contrast, pink and lavender in the light, and a soft bloom over it all. The dreamy one.": "Low contrast, pink and lavender in the light, and a soft bloom over it all. The dreamy one.","Low light opened up: shadows lifted with the noise softened before it rises, whites held, the blue of the night kept.": "Low light opened up: shadows lifted with the noise softened before it rises, whites held, the blue of the night kept.",@@ -540,6 +547,7 @@"My templates": "My templates","Name": "Name","Natural": "Natural",+ "natural": "natural","Neon": "Neon","Neon Edges": "Neon Edges","Neon Flicker": "Neon Flicker",@@ -597,15 +605,17 @@"Outline": "Outline","Output": "Output","Output · {0}": "Output · {0}",- "Pace": "Pace","Pan tool (H)": "Pan tool (H)","Party & Club": "Party & Club","Paste": "Paste","Pause": "Pause",+ "Pauses": "Pauses","Peach": "Peach","Period": "Period","Periodic horizontal slice displacement with chromatic aberration.": "Periodic horizontal slice displacement with chromatic aberration.","Person": "Person",+ "Pick a recording": "Pick a recording",+ "Pick a sample with a voice in it": "Pick a sample with a voice in it","Pick an effect or filter from the library": "Pick an effect or filter from the library","Pick one from the Transitions tab to dissolve into this clip from the cut before it.": "Pick one from the Transitions tab to dissolve into this clip from the cut before it.","Pink Fuzz": "Pink Fuzz",@@ -644,6 +654,7 @@"Push": "Push","Quality": "Quality","Quarter": "Quarter",+ "Quick": "Quick","Radial chromatic dispersion refracting RGB channels.": "Radial chromatic dispersion refracting RGB channels.","Radial ripple expansion pulsing with beat intensity.": "Radial ripple expansion pulsing with beat intensity.","Radio": "Radio",@@ -655,6 +666,8 @@"Rapid inward/outward camera rush with radial zoom blur.": "Rapid inward/outward camera rush with radial zoom blur.","Rate": "Rate","Rate re-times the clip in place, so the timeline length changes with it. Trim afterwards, not before. A curve varies the rate over the clip; the same footage plays, faster here and slower there.": "Rate re-times the clip in place, so the timeline length changes with it. Trim afterwards, not before. A curve varies the rate over the clip; the same footage plays, faster here and slower there.",+ "Reads in any voice from a few seconds of a recording: one it ships with, or a sample from the bin.": "Reads in any voice from a few seconds of a recording: one it ships with, or a sample from the bin.",+ "Reads in the voice heard in a recording from the bin. The first ten seconds from the point chosen below are what the model listens to.": "Reads in the voice heard in a recording from the bin. The first ten seconds from the point chosen below are what the model listens to.","Reads in the voice heard in the clip selected on the timeline": "Reads in the voice heard in the clip selected on the timeline","Reattach audio": "Reattach audio","Recent": "Recent",@@ -702,6 +715,7 @@"Row height": "Row height","Runs locally": "Runs locally","Sage": "Sage",+ "Sample": "Sample","Saturated and bright, the water pushed teal.": "Saturated and bright, the water pushed teal.","Saturation": "Saturation","Save": "Save",@@ -722,7 +736,6 @@"See all": "See all","Segments": "Segments","Select a clip on the timeline first": "Select a clip on the timeline first",- "Select a clip with a voice in it to clone": "Select a clip with a voice in it to clone","Select a video or image clip on the timeline first": "Select a video or image clip on the timeline first","Select a video, image or text clip on the timeline first": "Select a video, image or text clip on the timeline first","Select folder containing media files": "Select folder containing media files",@@ -765,7 +778,6 @@"Slide Left": "Slide Left","Slide Right": "Slide Right","Slide Up": "Slide Up",- "Slower": "Slower","Small": "Small","Smallest": "Smallest","Smart brush": "Smart brush",@@ -790,6 +802,7 @@"Space": "Space","Spanish": "Spanish","Sparkle": "Sparkle",+ "Speakers built into the model, in English and Chinese. Reads at the speed and with the pauses set below.": "Speakers built into the model, in English and Chinese. Reads at the speed and with the pauses set below.","Speech": "Speech","Speed": "Speed","Spin": "Spin",@@ -804,6 +817,7 @@"Strength": "Strength","Strobe Flash": "Strobe Flash","Stroke": "Stroke",+ "Studio voice · slow": "Studio voice · slow","Style": "Style","Stylised": "Stylised","Stylize": "Stylize",@@ -838,6 +852,7 @@"The centre of the picture bulges outward, or pinches inward below zero.": "The centre of the picture bulges outward, or pinches inward below zero.","The chain runs top to bottom — reorder it with the chevrons. The eye bypasses one link without losing the values you dialled into it.": "The chain runs top to bottom — reorder it with the chevrons. The eye bypasses one link without losing the values you dialled into it.","The clip is no longer on the timeline": "The clip is no longer on the timeline",+ "The closest to a studio voice. Reads at its own pace, in one of Pocket's two recordings or in any sample from the bin, and reads [laugh], [chuckle] and [sigh] as what they say.": "The closest to a studio voice. Reads at its own pace, in one of Pocket's two recordings or in any sample from the bin, and reads [laugh], [chuckle] and [sigh] as what they say.","The colour channels pull apart through the cut and snap back together.": "The colour channels pull apart through the cut and snap back together.","The colour channels pulled apart into a bold stylised fringe.": "The colour channels pulled apart into a bold stylised fringe.","The cut twists both pictures around its centre and untwists into the next shot.": "The cut twists both pictures around its centre and untwists into the next shot.",@@ -873,6 +888,7 @@"These settings apply to the whole edit and cannot be changed later.": "These settings apply to the whole edit and cannot be changed later.","This clip has no file to transcribe": "This clip has no file to transcribe","This file has no picture to enhance": "This file has no picture to enhance",+ "This model reads only with its own speakers": "This model reads only with its own speakers","Threshold": "Threshold","Tiles": "Tiles","Tilt Shift": "Tilt Shift",@@ -917,6 +933,7 @@"Unpacking…": "Unpacking…","Untitled project": "Untitled project","Up or down by semitones, the length untouched.": "Up or down by semitones, the length untouched.",+ "Use sample voice": "Use sample voice","Vaporwave": "Vaporwave","Vast stadium echoes and reverberations across a massive arena.": "Vast stadium echoes and reverberations across a massive arena.","VBR": "VBR",@@ -939,6 +956,7 @@"Vivid Landscape": "Vivid Landscape","Voice": "Voice","Voice added to the timeline": "Voice added to the timeline",+ "Voice from": "Voice from","Voices": "Voices","Volume": "Volume","Vortex Swirl": "Vortex Swirl",@@ -984,6 +1002,7 @@"{0} media file(s) not found": "{0} media file(s) not found","{0} minutes ago": "{0} minutes ago","{0} months ago": "{0} months ago",+ "{0} s in": "{0} s in","{0} strokes": "{0} strokes","{0}m {1}s left": "{0}m {1}s left","{0}s left": "{0}s left"diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.jsonindex 4d05bb0f..2e9387ba 100644--- a/src/crates/concat/locales/es.json+++ b/src/crates/concat/locales/es.json@@ -203,7 +203,6 @@"Fade in": "Fundido de entrada","Fade out": "Fundido de salida","Fades": "Fundidos",- "Faster": "Más rápido","Favourites": "Favoritos","Feather": "Difuminado","female": "femenina",@@ -358,7 +357,6 @@"Outline": "Contorno","Output": "Salida","Output · {0}": "Salida · {0}",- "Pace": "Ritmo","Paste": "Pegar","Pause": "Pausa","Person": "Persona",@@ -449,7 +447,6 @@"Slide Left": "Deslizar a la izquierda","Slide Right": "Deslizar a la derecha","Slide Up": "Deslizar arriba",- "Slower": "Más lento","Small": "Pequeño","Smart brush": "Pincel inteligente","Smart brush: {0}": "Pincel inteligente: {0}",diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.jsonindex 6befb7f4..47d57e55 100644--- a/src/crates/concat/locales/fa.json+++ b/src/crates/concat/locales/fa.json@@ -234,7 +234,6 @@"Fades": "محوها","Fair": "متعادل","Falling Dust": "گردوغبار در حال سقوط",- "Faster": "سریعتر","Favourites": "علاقهمندیها","Feather": "نرمی لبه","female": "زن",@@ -443,7 +442,6 @@"Outline": "حاشیه","Output": "خروجی","Output · {0}": "خروجی · {0}",- "Pace": "سرعت","Pan tool (H)": "ابزار Pan (H)","Turn on Preview Axis (S)": "روشن کردن محور پیشنمایش (S)","Turn off Preview Axis (S)": "خاموش کردن محور پیشنمایش (S)",@@ -572,7 +570,6 @@"Slide Left": "اسلاید به چپ","Slide Right": "اسلاید به راست","Slide Up": "اسلاید به بالا",- "Slower": "کندتر","Small": "کوچک","Smallest": "کوچکترین","Smart brush": "قلمموی هوشمند",diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.jsonindex 14f04826..2574925e 100644--- a/src/crates/concat/locales/fr.json+++ b/src/crates/concat/locales/fr.json@@ -203,7 +203,6 @@"Fade in": "Fondu d'entrée","Fade out": "Fondu de sortie","Fades": "Fondus",- "Faster": "Plus rapide","Favourites": "Favoris","Feather": "Contour progressif","female": "féminine",@@ -358,7 +357,6 @@"Outline": "Contour","Output": "Sortie","Output · {0}": "Sortie · {0}",- "Pace": "Rythme","Paste": "Coller","Pause": "Pause","Person": "Personne",@@ -449,7 +447,6 @@"Slide Left": "Glisser vers la gauche","Slide Right": "Glisser vers la droite","Slide Up": "Glisser vers le haut",- "Slower": "Plus lent","Small": "Petit","Smart brush": "Pinceau intelligent","Smart brush: {0}": "Pinceau intelligent : {0}",diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.jsonindex b1a06299..331bf53b 100644--- a/src/crates/concat/locales/hr.json+++ b/src/crates/concat/locales/hr.json@@ -250,7 +250,6 @@"Fades": "Izblijedjenja","Fair": "Svijetlo","Falling Dust": "Padajuća prašina",- "Faster": "Brže","Favourites": "Favoriti","Feather": "Omekšanje","female": "ženski",@@ -445,7 +444,6 @@"Outline": "Kontura","Output": "Izlaz","Output · {0}": "Izlaz · {0}",- "Pace": "Tempo","Paste": "Zalijepi","Pause": "Pauza","Peach": "Breskva",@@ -558,7 +556,6 @@"Slide Left": "Klizanje lijevo","Slide Right": "Klizanje desno","Slide Up": "Klizanje gore",- "Slower": "Sporije","Small": "Malo","Smart brush": "Pametna četka","Smart brush: {0}": "Pametna četka: {0}",diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.jsonindex 020ac784..60af0ae6 100644--- a/src/crates/concat/locales/it.json+++ b/src/crates/concat/locales/it.json@@ -203,7 +203,6 @@"Fade in": "Dissolvenza in entrata","Fade out": "Dissolvenza in uscita","Fades": "Dissolvenze",- "Faster": "Più veloce","Favourites": "Preferiti","Feather": "Sfumatura","female": "femminile",@@ -358,7 +357,6 @@"Outline": "Contorno","Output": "Uscita","Output · {0}": "Uscita · {0}",- "Pace": "Ritmo","Paste": "Incolla","Pause": "Pausa","Person": "Persona",@@ -449,7 +447,6 @@"Slide Left": "Scorri a sinistra","Slide Right": "Scorri a destra","Slide Up": "Scorri in alto",- "Slower": "Più lento","Small": "Piccolo","Smart brush": "Pennello intelligente","Smart brush: {0}": "Pennello intelligente: {0}",diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.jsonindex 5a2cea99..590b7008 100644--- a/src/crates/concat/locales/ja.json+++ b/src/crates/concat/locales/ja.json@@ -203,7 +203,6 @@"Fade in": "フェードイン","Fade out": "フェードアウト","Fades": "フェード",- "Faster": "速く","Favourites": "お気に入り","Feather": "ぼかし","female": "女性",@@ -358,7 +357,6 @@"Outline": "縁取り","Output": "出力","Output · {0}": "出力 · {0}",- "Pace": "速さ","Paste": "ペースト","Pause": "一時停止","Person": "人物",@@ -449,7 +447,6 @@"Slide Left": "左へスライド","Slide Right": "右へスライド","Slide Up": "上へスライド",- "Slower": "遅く","Small": "小","Smart brush": "スマートブラシ","Smart brush: {0}": "スマートブラシ: {0}",diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.jsonindex 344b4317..5e4d720b 100644--- a/src/crates/concat/locales/ko.json+++ b/src/crates/concat/locales/ko.json@@ -203,7 +203,6 @@"Fade in": "페이드 인","Fade out": "페이드 아웃","Fades": "페이드",- "Faster": "빠르게","Favourites": "즐겨찾기","Feather": "페더","female": "여성",@@ -358,7 +357,6 @@"Outline": "외곽선","Output": "출력","Output · {0}": "출력 · {0}",- "Pace": "속도","Paste": "붙여넣기","Pause": "일시 정지","Person": "인물",@@ -449,7 +447,6 @@"Slide Left": "왼쪽으로 슬라이드","Slide Right": "오른쪽으로 슬라이드","Slide Up": "위로 슬라이드",- "Slower": "느리게","Small": "작게","Smart brush": "스마트 브러시","Smart brush: {0}": "스마트 브러시: {0}",diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.jsonindex fab8b096..4b99464a 100644--- a/src/crates/concat/locales/pt-BR.json+++ b/src/crates/concat/locales/pt-BR.json@@ -203,7 +203,6 @@"Fade in": "Fade de entrada","Fade out": "Fade de saída","Fades": "Fades",- "Faster": "Mais rápido","Favourites": "Favoritos","Feather": "Suavização","female": "feminina",@@ -358,7 +357,6 @@"Outline": "Contorno","Output": "Saída","Output · {0}": "Saída · {0}",- "Pace": "Ritmo","Paste": "Colar","Pause": "Pausar","Person": "Pessoa",@@ -449,7 +447,6 @@"Slide Left": "Deslizar para a esquerda","Slide Right": "Deslizar para a direita","Slide Up": "Deslizar para cima",- "Slower": "Mais lento","Small": "Pequeno","Smart brush": "Pincel inteligente","Smart brush: {0}": "Pincel inteligente: {0}",diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.jsonindex 49eb4df0..c35de0ff 100644--- a/src/crates/concat/locales/ru.json+++ b/src/crates/concat/locales/ru.json@@ -203,7 +203,6 @@"Fade in": "Нарастание","Fade out": "Затухание","Fades": "Плавные переходы",- "Faster": "Быстрее","Favourites": "Избранное","Feather": "Растушёвка","female": "женский",@@ -358,7 +357,6 @@"Outline": "Обводка","Output": "Вывод","Output · {0}": "Вывод · {0}",- "Pace": "Темп","Paste": "Вставить","Pause": "Пауза","Person": "Человек",@@ -449,7 +447,6 @@"Slide Left": "Сдвиг влево","Slide Right": "Сдвиг вправо","Slide Up": "Сдвиг вверх",- "Slower": "Медленнее","Small": "Малый","Smart brush": "Умная кисть","Smart brush: {0}": "Умная кисть: {0}",diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.jsonindex f831e7a1..5bb39896 100644--- a/src/crates/concat/locales/tr.json+++ b/src/crates/concat/locales/tr.json@@ -203,7 +203,6 @@"Fade in": "Açılma","Fade out": "Kararma","Fades": "Geçişler",- "Faster": "Daha hızlı","Favourites": "Favoriler","Feather": "Yumuşatma","female": "kadın",@@ -358,7 +357,6 @@"Outline": "Dış çizgi","Output": "Çıktı","Output · {0}": "Çıkış · {0}",- "Pace": "Tempo","Paste": "Yapıştır","Pause": "Duraklat","Person": "Kişi",@@ -449,7 +447,6 @@"Slide Left": "Sola kay","Slide Right": "Sağa kay","Slide Up": "Yukarı kay",- "Slower": "Daha yavaş","Small": "Küçük","Smart brush": "Akıllı fırça","Smart brush: {0}": "Akıllı fırça: {0}",diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.jsonindex 1bbf23ed..4074df7a 100644--- a/src/crates/concat/locales/zh-Hans.json+++ b/src/crates/concat/locales/zh-Hans.json@@ -203,7 +203,6 @@"Fade in": "淡入","Fade out": "淡出","Fades": "淡入淡出",- "Faster": "更快","Favourites": "收藏","Feather": "羽化","female": "女声",@@ -358,7 +357,6 @@"Outline": "描边","Output": "输出","Output · {0}": "输出 · {0}",- "Pace": "语速","Paste": "粘贴","Pause": "暂停","Person": "人物",@@ -449,7 +447,6 @@"Slide Left": "左滑","Slide Right": "右滑","Slide Up": "上滑",- "Slower": "更慢","Small": "小","Smart brush": "智能画笔","Smart brush: {0}": "智能画笔:{0}",diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.jsonindex 174231d7..634ff129 100644--- a/src/crates/concat/locales/zh-TW.json+++ b/src/crates/concat/locales/zh-TW.json@@ -314,7 +314,6 @@"Fades": "淡入淡出","Fair": "透亮","Falling Dust": "飄塵",- "Faster": "較快","Favourites": "收藏","Feather": "羽化","Featured": "精選",@@ -589,7 +588,6 @@"Outline": "外框","Output": "輸出","Output · {0}": "輸出 · {0}",- "Pace": "語速","Pan tool (H)": "平移工具 (H)","Turn on Preview Axis (S)": "開啟預覽軸 (S)","Turn off Preview Axis (S)": "關閉預覽軸 (S)",@@ -714,7 +712,6 @@"Search {0}s": "搜尋{0}","Segments": "分段數","Select a clip on the timeline first": "請先在時間軸上選取片段",- "Select a clip with a voice in it to clone": "請選取一段帶有人聲的片段,以複製其聲音","Select a video or image clip on the timeline first": "請先選取時間軸上的影片或圖片片段","Select a video, image or text clip on the timeline first": "請先在時間軸上選取影片、圖片或文字片段","Select folder containing media files": "選擇包含媒體檔案的資料夾",@@ -756,7 +753,6 @@"Slide Left": "向左滑動","Slide Right": "向右滑動","Slide Up": "向上滑動",- "Slower": "較慢","Small": "小","Smallest": "最小","Smart brush": "智慧筆刷",diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rsindex f639fa2a..93e9ac86 100644--- a/src/crates/concat/src/lib.rs+++ b/src/crates/concat/src/lib.rs@@ -199,8 +199,12 @@ pub fn run() -> Result<(), slint::PlatformError> {editor.set_menu_items(ModelRc::from(models.menu.clone()));app.set_caption_models(ModelRc::from(models.caption_models.clone()));app.set_speech_models(ModelRc::from(models.speech_models.clone()));+ app.set_speech_model_details(ModelRc::from(models.speech_model_details.clone()));app.set_speech_voices(ModelRc::from(models.speakers.clone()));app.set_speech_voice_details(ModelRc::from(models.speaker_details.clone()));+ app.set_speech_samples(ModelRc::from(models.speech_samples.clone()));+ app.set_speech_sample_waves(ModelRc::from(models.speech_sample_waves.clone()));+ app.set_speech_sample_details(ModelRc::from(models.speech_sample_details.clone()));app.set_app_menu_items(ModelRc::from(models.bar.clone()));app.set_transcribers(ModelRc::from(models.transcribers.clone()));app.set_voices(ModelRc::from(models.voices.clone()));@@ -1272,9 +1276,29 @@ pub fn run() -> Result<(), slint::PlatformError> {app.on_speech_model_changed(on_window!(|state, index: i32| {state.handle(Msg::Speech(SpeechMsg::ModelChanged(index)));}));- app.on_speech_pace_changed(on_window!(|state, index: i32| {- state.handle(Msg::Speech(SpeechMsg::PaceChanged(index)));+ app.on_speech_speed_changed(on_window!(|state, value: f32| {+ state.handle(Msg::Speech(SpeechMsg::SpeedChanged(value)));}));+ app.on_speech_quality_changed(on_window!(|state, index: i32| {+ state.handle(Msg::Speech(SpeechMsg::QualityChanged(index)));+ }));+ app.on_speech_pauses_changed(on_window!(|state, value: f32| {+ state.handle(Msg::Speech(SpeechMsg::PausesChanged(value)));+ }));+ app.on_speech_reference_start_changed(on_window!(|state, seconds: f32| {+ state.handle(Msg::Speech(SpeechMsg::ReferenceStartChanged(seconds)));+ }));+ app.on_speech_use_sample_changed(on_window!(|state, on: bool| {+ state.handle(Msg::Speech(SpeechMsg::UseSampleChanged(on)));+ }));+ app.on_speech_sample_changed(on_window!(|state, index: i32| {+ state.handle(Msg::Speech(SpeechMsg::SampleChanged(index)));+ }));+ // A string cut, and nothing of the window's: the sheet keeps the text,+ // Rust only knows where a character starts.+ app.on_speech_insert_tag(|text: SharedString, tag: SharedString, at: i32| {+ panes::speech::insert_tag(text.as_str(), tag.as_str(), at.max(0) as usize).into()+ });app.on_speech_begin(on_window!(|state| {state.handle(Msg::Speech(SpeechMsg::Begin));}));diff --git a/src/crates/concat/src/panes/speech.rs b/src/crates/concat/src/panes/speech.rsindex dd91f2ed..51f6ce56 100644--- a/src/crates/concat/src/panes/speech.rs+++ b/src/crates/concat/src/panes/speech.rs@@ -8,15 +8,29 @@//! chosen last time. The synthesiser runs on a worker and reports as//! [`SpeechMsg::Progress`], ending as [`SpeechMsg::Finished`] with the//! written file, which lands in the bin and on the timeline.+//!+//! The model comes first and decides the rest: which voices are offered,+//! and which dials. Kokoro reads with built-in speakers at a speed and+//! with a pause of your choosing; Pocket reads in a recording, at a speed,+//! with a pause, and at a quality that is its flow steps; Chatterbox reads+//! at its own pace and knows the expression tags. Either of the two that+//! read in a recording can read in a sample voice instead of a named one:+//! a recording from the bin, chosen by its waveform, from a point in it of+//! the sheet's choosing. The sheet shows each model its own controls rather+//! than the few every model shares, which is why the pane carries every+//! dial and the family says which are read.use std::sync::Arc;use concat_host::media::{self, MediaSummary};use concat_project::Command;-use concat_project::model::{ClipKind, MediaOrigin};-use concat_speech::tts::{CHATTERBOX_CLONE, Family, Reference, VoiceInfo, family_of, is_clone};+use concat_project::model::{ClipKind, MediaItem, MediaOrigin};+use concat_speech::tts::{+ CHATTERBOX_CLONE, Family, POCKET_CLONE, Reference, VoiceInfo, family_of, is_clone,+};use slint::SharedString;+use crate::format::wave_path;use crate::host::{on_ui, spawn};use crate::i18n::{t, tf};use crate::panes::Msg;@@ -29,8 +43,16 @@ use crate::ui::SpeechSheetData;const DEFAULT_VOICE: i32 = 3;/// The default Pocket voice: Bria, the bundle's first recording.const DEFAULT_POCKET_VOICE: i32 = 1000;-/// The paces the speech sheet offers, as the voice's rate multiplier.-const PACES: [f32; 3] = [0.85, 1.0, 1.15];+/// The default Chatterbox voice: the same recording, read by Chatterbox.+const DEFAULT_CHATTERBOX_VOICE: i32 = 2000;+/// The speeds a voice can be asked for, as the rate multiplier the sheet's+/// slider runs over; 1 is the voice's own.+const SPEEDS: (f32, f32) = (0.5, 2.0);+/// Pocket's flow steps behind the sheet's three qualities: quick, the+/// engine's own, and fine.+const STEPS: [i32; 3] = [3, 5, 8];+/// The breath between sentences the sheet opens on: sherpa's own.+const DEFAULT_PAUSES: f32 = 0.2;/// Everything that can happen to the speech sheet.#[derive(Clone, Debug)]@@ -41,7 +63,18 @@ pub enum SpeechMsg {TextEdited(String),VoiceChanged(i32),ModelChanged(i32),- PaceChanged(i32),+ /// The rate, `0.5..=2`.+ SpeedChanged(f32),+ /// Pocket's quality: a row of [`STEPS`].+ QualityChanged(i32),+ /// The breath between sentences, `0..=1`.+ PausesChanged(f32),+ /// Seconds into the sample the voice is taken from.+ ReferenceStartChanged(f32),+ /// Read in a sample from the bin rather than a named voice.+ UseSampleChanged(bool),+ /// Which sample: a row of [`SpeechPane::samples`].+ SampleChanged(i32),/// Read the script.Begin,Cancel,@@ -64,10 +97,24 @@ pub struct SpeechPane {pub voice: usize,/// Row in the installed voice model list.pub model: usize,- /// The family of the chosen model, which is which voices are offered.+ /// The family of the chosen model, which is which voices are offered+ /// and which of the dials below are read.pub family: Family,- /// 0 slower, 1 natural, 2 faster.- pub pace: usize,+ /// The rate, `0.5..=2`; Kokoro and Pocket.+ pub speed: f32,+ /// Row of [`STEPS`]; Pocket.+ pub quality: usize,+ /// The breath between sentences, `0..=1`; Kokoro and Pocket.+ pub pauses: f32,+ /// Reading in a sample from the bin rather than a named voice; Pocket+ /// and Chatterbox, the two that read in a recording.+ pub use_sample: bool,+ /// Row of [`SpeechPane::samples`]: which recording.+ pub sample: usize,+ /// Seconds into the sample the voice is taken from: the first ten+ /// seconds from there are what the model listens to, and the start of+ /// a recording is not always where the speaking is.+ pub reference_start: f64,pub running: bool,pub progress: f32,pub message: String,@@ -103,13 +150,21 @@ impl SpeechPane {voice: 0,model,family,- pace: 1,+ speed: 1.0,+ quality: 1,+ pauses: DEFAULT_PAUSES,+ use_sample: false,+ sample: 0,+ reference_start: 0.0,speakers: std::mem::take(&mut self.speakers),..SpeechPane::default()};- // The voice chosen last time, if the model reads with it.+ // The voice chosen last time, if the model reads with it;+ // and the selected clip's recording as the sample to start+ // from, since that is the voice most likely wanted.let wanted = studio.prefs.tts_voice;self.voice = self.voice_row(wanted);+ self.sample = self.default_sample(studio);}SpeechMsg::Close => self.open = false,SpeechMsg::TextEdited(text) => self.text = text,@@ -125,7 +180,35 @@ impl SpeechPane {.unwrap_or(Family::Kokoro);self.voice = self.voice_row(chosen);}- SpeechMsg::PaceChanged(index) => self.pace = (index.max(0) as usize).min(2),+ SpeechMsg::SpeedChanged(speed) => {+ self.speed = if speed.is_finite() {+ speed.clamp(SPEEDS.0, SPEEDS.1)+ } else {+ 1.0+ }+ }+ SpeechMsg::QualityChanged(index) => {+ self.quality = (index.max(0) as usize).min(STEPS.len() - 1)+ }+ SpeechMsg::PausesChanged(pauses) => {+ self.pauses = if pauses.is_finite() {+ pauses.clamp(0.0, 1.0)+ } else {+ DEFAULT_PAUSES+ }+ }+ SpeechMsg::ReferenceStartChanged(seconds) => {+ self.reference_start = if seconds.is_finite() {+ f64::from(seconds.max(0.0))+ } else {+ 0.0+ }+ }+ SpeechMsg::UseSampleChanged(on) => self.use_sample = on,+ SpeechMsg::SampleChanged(index) => {+ self.sample = index.max(0) as usize;+ self.reference_start = 0.0;+ }SpeechMsg::Begin => self.run(studio),SpeechMsg::Cancel => {studio.host.speech.cancel();@@ -182,34 +265,41 @@ impl SpeechPane {self.message = t("Download a voice model in Settings › Speech first");return;};- let Some(voice) = self.offered().get(self.voice).map(|speaker| speaker.id) else {- self.message = t("No voice to read with");- return;- };- // The clone reads in the voice of the selected clip: its file,- // from where the clip starts in it.- let reference = if is_clone(voice) {- let recording = studio- .sole_selection()- .and_then(|id| studio.clip(&id))- .filter(|clip| clip.kind == ClipKind::Video || clip.kind == ClipKind::Audio)- .and_then(|clip| {- studio- .project()- .media_by_id(&clip.media_id)- .filter(|media| media.has_audio)- .map(|media| Reference {- path: media.path.clone(),- start: clip.source_start,- })- });- let Some(recording) = recording else {- self.message = t("Select a clip with a voice in it to clone");+ // A sample voice is a recording of the sheet's choosing, handed over+ // as the request's reference under the family's own id for one.+ // Otherwise the voice is one the model names - and Chatterbox may+ // name none, since its stock voices are Pocket's recordings and+ // are only there while Pocket is.+ let (voice, reference) = if self.use_sample {+ let Some(voice) = self.sample_voice() else {+ self.message = t("This model reads only with its own speakers");+ return;+ };+ let Some(sample) = self.sample_media(studio).cloned() else {+ self.message = t("Pick a sample with a voice in it");return;};- Some(recording)+ let start = self.reference_offset(sample.duration.unwrap_or(0.0));+ (+ voice,+ Some(Reference {+ path: sample.path,+ start,+ }),+ )} else {- None+ let Some(voice) = self.offered().get(self.voice).map(|speaker| speaker.id) else {+ self.message = if self.family == Family::Chatterbox {+ t(+ "Chatterbox has no voice of its own: turn on Use sample voice, or \+ download Pocket TTS for its two recordings",+ )+ } else {+ t("No voice to read with")+ };+ return;+ };+ (voice, None)};let Some(project) = studio.session@@ -218,9 +308,12 @@ impl SpeechPane {else {return;};- // Remembered: the voice chosen is the voice wanted next time.- studio.prefs.tts_voice = Some(voice);- studio.prefs.save(&studio.host.dirs);+ // Remembered: the voice chosen is the voice wanted next time. A+ // sample is a recording in one project, and is not.+ if !self.use_sample {+ studio.prefs.tts_voice = Some(voice);+ studio.prefs.save(&studio.host.dirs);+ }self.landing = self.clip.as_ref()@@ -232,7 +325,10 @@ impl SpeechPane {voice,reference,text,- speed: PACES[self.pace.min(2)],+ speed: self.rate(),+ pauses: self.reads_at_a_pace().then_some(self.pauses),+ steps: (self.family == Family::Pocket)+ .then(|| STEPS[self.quality.min(STEPS.len() - 1)]),project,};let dirs = studio.host.dirs.clone();@@ -257,29 +353,102 @@ impl SpeechPane {}/// What the sheet's script would take to say, for the line under it.- fn estimate(&self) -> String {+ fn estimate(&self, studio: &Studio) -> String {let chars = self.text.trim().chars().count();if chars == 0 {return t("Nothing to read yet");}- let seconds = chars as f32 / CHARS_PER_SECOND / PACES[self.pace.min(2)];+ let seconds = chars as f32 / CHARS_PER_SECOND / self.rate();let whole = seconds.round() as i32;- let voice = self- .offered()- .get(self.voice)- .map(|speaker| voice_label(&speaker.name).0)- .unwrap_or_default();+ let voice = if self.use_sample {+ self.sample_media(studio)+ .map(|sample| sample.name.clone())+ .unwrap_or_default()+ } else {+ self.offered()+ .get(self.voice)+ .map(|speaker| voice_label(&speaker.name).0)+ .unwrap_or_default()+ };tf("About {0}:{1} in {2} · {3} characters",&[&(whole / 60), &format!("{:02}", whole % 60), &voice, &chars],)}+ /// Whether the chosen model reads at a speed and with a pause of the+ /// sheet's choosing. Chatterbox does neither: it reads at its own+ /// pace, and the sheet does not offer what the engine would ignore.+ pub fn reads_at_a_pace(&self) -> bool {+ self.family != Family::Chatterbox+ }++ /// The rate the request carries: the slider's, or 1 for a model that+ /// reads at its own.+ fn rate(&self) -> f32 {+ if self.reads_at_a_pace() {+ self.speed+ } else {+ 1.0+ }+ }++ /// The id under which the chosen model reads in a recording of the+ /// sheet's choosing; None for a model that reads only with its own+ /// speakers.+ fn sample_voice(&self) -> Option<i32> {+ match self.family {+ Family::Kokoro => None,+ Family::Pocket => Some(POCKET_CLONE),+ Family::Chatterbox => Some(CHATTERBOX_CLONE),+ }+ }++ /// The recordings a voice can be taken from: everything in the bin with+ /// sound in it, in the bin's order.+ pub fn samples<'a>(&self, studio: &'a Studio) -> Vec<&'a MediaItem> {+ studio+ .project()+ .media+ .iter()+ .filter(|item| item.has_audio)+ .collect()+ }++ /// The chosen sample.+ fn sample_media<'a>(&self, studio: &'a Studio) -> Option<&'a MediaItem> {+ self.samples(studio).get(self.sample).copied()+ }++ /// The row to open the sample list on: the selected clip's recording,+ /// when one clip with sound in it is selected, else the first.+ fn default_sample(&self, studio: &Studio) -> usize {+ studio+ .sole_selection()+ .and_then(|id| studio.clip(&id))+ .filter(|clip| clip.kind == ClipKind::Video || clip.kind == ClipKind::Audio)+ .and_then(|clip| {+ self.samples(studio)+ .iter()+ .position(|item| item.id == clip.media_id)+ })+ .unwrap_or(0)+ }++ /// How far into a recording of `duration` the voice is taken from: what+ /// the sheet asked for, held short of the end so there is always at+ /// least a second of sound left to listen to.+ fn reference_offset(&self, duration: f64) -> f64 {+ self.reference_start.clamp(0.0, (duration - 1.0).max(0.0))+ }+/// The voices the chosen model reads with, in table order.pub fn offered(&self) -> Vec<&VoiceInfo> {+ // The family's clone id is not a voice to pick from a list: it is+ // what a sample is sent under, and the sample switch offers it.self.speakers.iter()- .filter(|speaker| speaker.family == self.family)+ .filter(|speaker| speaker.family == self.family && !is_clone(speaker.id)).collect()}@@ -290,7 +459,7 @@ impl SpeechPane {let default = match self.family {Family::Kokoro => DEFAULT_VOICE,Family::Pocket => DEFAULT_POCKET_VOICE,- Family::Chatterbox => CHATTERBOX_CLONE,+ Family::Chatterbox => DEFAULT_CHATTERBOX_VOICE,};wanted.and_then(|id| offered.iter().position(|voice| voice.id == id))@@ -315,14 +484,80 @@ impl SpeechPane {.collect()}+ /// The model list's second lines: what each model is for, in a few+ /// words, since which one is chosen decides everything under it.+ pub fn model_detail_rows(&self, studio: &Studio) -> Vec<SharedString> {+ installed(&studio.settings.voices)+ .iter()+ .map(|model| match family_of(&model.id) {+ Family::Kokoro => t("Built-in speakers · fast"),+ Family::Pocket => t("Any voice, from a recording"),+ Family::Chatterbox => t("Studio voice · slow"),+ })+ .map(SharedString::from)+ .collect()+ }++ /// The sample list's rows: each recording's name.+ pub fn sample_rows(&self, studio: &Studio) -> Vec<SharedString> {+ self.samples(studio)+ .iter()+ .map(|item| item.name.as_str().into())+ .collect()+ }++ /// The sample list's pictures: each recording's envelope as path+ /// commands, the same drawing the bin's card and the timeline's clip+ /// make of it, or empty while the peaks have not been read yet.+ pub fn sample_wave_rows(&self, studio: &Studio) -> Vec<SharedString> {+ self.samples(studio)+ .iter()+ .map(|item| match studio.peaks.get(&item.id) {+ Some(peaks) => {+ wave_path(peaks, 0.0, item.duration.unwrap_or(0.0) as f32, 64, 0.75).into()+ }+ None => SharedString::new(),+ })+ .collect()+ }++ /// The sample list's second column: how long each recording is.+ pub fn sample_detail_rows(&self, studio: &Studio) -> Vec<SharedString> {+ self.samples(studio)+ .iter()+ .map(|item| {+ let whole = item.duration.unwrap_or(0.0).round() as i64;+ format!("{}:{:02}", whole / 60, whole % 60).into()+ })+ .collect()+ }+/// The sheet as Slint shows it.pub fn data(&self, studio: &Studio) -> SpeechSheetData {+ let sample = self.sample_media(studio);+ let length = sample.and_then(|item| item.duration).unwrap_or(0.0);SpeechSheetData {open: self.open,text: self.text.as_str().into(),voice: self.voice as i32,model: self.model as i32,- pace: self.pace as i32,+ family: match self.family {+ Family::Kokoro => 0,+ Family::Pocket => 1,+ Family::Chatterbox => 2,+ },+ speed: self.speed,+ quality: self.quality as i32,+ pauses: self.pauses,+ samples_offered: self.sample_voice().is_some(),+ use_sample: self.use_sample,+ sample: self.sample as i32,+ sample_name: sample+ .map(|item| item.name.as_str())+ .unwrap_or_default()+ .into(),+ reference_length: length as f32,+ reference_start: self.reference_offset(length) as f32,running: self.running,progress: self.progress,ready: !installed(&studio.settings.voices).is_empty(),@@ -332,12 +567,37 @@ impl SpeechPane {"at the playhead"}.into(),- estimate: self.estimate().into(),+ estimate: self.estimate(studio).into(),message: self.message.as_str().into(),}}}+/// `tag` written into `text` at byte offset `at` - the caret, as the script+/// box reports it - with a space on whichever side is against a word, so+/// `[laugh]` lands as a word of its own and never as the tail of one. An+/// offset inside a character steps back to the character's start; one past+/// the end is the end. A trailing space is always written when the tag is+/// not already followed by one, so the caller can put the caret after it.+pub fn insert_tag(text: &str, tag: &str, at: usize) -> String {+ let mut at = at.min(text.len());+ while !text.is_char_boundary(at) {+ at -= 1;+ }+ let (before, after) = text.split_at(at);+ let lead = if before.is_empty() || before.ends_with(char::is_whitespace) {+ ""+ } else {+ " "+ };+ let trail = if after.starts_with(char::is_whitespace) {+ ""+ } else {+ " "+ };+ format!("{before}{lead}{tag}{trail}{after}")+}+/// "af_heart" as a person would say it: the name, and the accent and/// gender its prefix encodes. A Pocket voice says where it comes from.fn voice_label(name: &str) -> (String, String) {@@ -388,7 +648,27 @@ fn voice_label(name: &str) -> (String, String) {#[cfg(test)]mod tests {- use super::voice_label;+ use super::{insert_tag, voice_label};++ /// A tag lands as a word of its own wherever the caret is: spaced off a+ /// word on either side, not doubled against a space already there, and+ /// snapped to a character when the caret is reported inside one.+ #[test]+ fn a_tag_lands_as_its_own_word() {+ assert_eq!(insert_tag("", "[laugh]", 0), "[laugh] ");+ assert_eq!(insert_tag("hello", "[laugh]", 5), "hello [laugh] ");+ assert_eq!(insert_tag("hello world", "[sigh]", 5), "hello [sigh] world");+ assert_eq!(insert_tag("hello world", "[sigh]", 6), "hello [sigh] world");+ assert_eq!(+ insert_tag("hello world", "[sigh]", 3),+ "hel [sigh] lo world"+ );+ assert_eq!(insert_tag("hi", "[chuckle]", 0), "[chuckle] hi");+ // Past the end is the end; inside "é" (two bytes) steps back to it.+ assert_eq!(insert_tag("hi", "[laugh]", 40), "hi [laugh] ");+ assert_eq!(insert_tag("café", "[laugh]", 4), "caf [laugh] é");+ assert_eq!(insert_tag("café ", "[laugh]", 6), "café [laugh] ");+ }#[test]fn a_voice_name_reads_as_a_person_would_say_it() {diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex 5b9cc278..f5285bef 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -495,8 +495,12 @@ pub struct Models {/// The sheets' option lists: what is installed, and who can speak.pub caption_models: Rc<VecModel<SharedString>>,pub speech_models: Rc<VecModel<SharedString>>,+ pub speech_model_details: Rc<VecModel<SharedString>>,pub speakers: Rc<VecModel<SharedString>>,pub speaker_details: Rc<VecModel<SharedString>>,+ pub speech_samples: Rc<VecModel<SharedString>>,+ pub speech_sample_waves: Rc<VecModel<SharedString>>,+ pub speech_sample_details: Rc<VecModel<SharedString>>,pub transcribers: Rc<VecModel<ModelData>>,pub voices: Rc<VecModel<ModelData>>,pub seats: Rc<VecModel<SeatBox>>,@@ -536,8 +540,12 @@ impl Models {bar: Rc::new(VecModel::default()),caption_models: Rc::new(VecModel::default()),speech_models: Rc::new(VecModel::default()),+ speech_model_details: Rc::new(VecModel::default()),speakers: Rc::new(VecModel::default()),speaker_details: Rc::new(VecModel::default()),+ speech_samples: Rc::new(VecModel::default()),+ speech_sample_waves: Rc::new(VecModel::default()),+ speech_sample_details: Rc::new(VecModel::default()),transcribers: Rc::new(VecModel::default()),voices: Rc::new(VecModel::default()),seats: Rc::new(VecModel::default()),@@ -6520,8 +6528,21 @@ impl Studio {.map(|model| SharedString::from(model.name.as_str())).collect(),);+ sync(+ &models.speech_model_details,+ self.speech.model_detail_rows(self),+ );sync(&models.speakers, self.speech.speaker_rows());sync(&models.speaker_details, self.speech.speaker_detail_rows());+ sync(&models.speech_samples, self.speech.sample_rows(self));+ sync(+ &models.speech_sample_waves,+ self.speech.sample_wave_rows(self),+ );+ sync(+ &models.speech_sample_details,+ self.speech.sample_detail_rows(self),+ );app.set_speech(self.speech.data(self));let bar = self.menu_bar();diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slintindex 1a9e5a4f..bfb8f18a 100644--- a/src/crates/concat/ui/app.slint+++ b/src/crates/concat/ui/app.slint@@ -247,13 +247,26 @@ export component App inherits Window {in property <SpeechSheetData> speech;in property <[string]> speech-models;+ in property <[string]> speech-model-details;in property <[string]> speech-voices;in property <[string]> speech-voice-details;+ /// The recordings in the bin a voice can be taken from: their names,+ /// their waveforms as path commands, and their lengths.+ in property <[string]> speech-samples;+ in property <[string]> speech-sample-waves;+ in property <[string]> speech-sample-details;callback speech-closed();callback speech-text-edited(text: string);callback speech-voice-changed(index: int);callback speech-model-changed(index: int);- callback speech-pace-changed(index: int);+ callback speech-speed-changed(value: float);+ callback speech-quality-changed(index: int);+ callback speech-pauses-changed(value: float);+ callback speech-reference-start-changed(seconds: float);+ callback speech-use-sample-changed(on: bool);+ callback speech-sample-changed(index: int);+ /// See SpeechDialog.insert-tag: a string cut Rust does for the sheet.+ pure callback speech-insert-tag(text: string, tag: string, at: int) -> string;callback speech-begin();callback speech-cancel();@@ -597,14 +610,24 @@ export component App inherits Window {height: root.height;data: root.speech;models: root.speech-models;+ model-details: root.speech-model-details;voices: root.speech-voices;voice-details: root.speech-voice-details;+ samples: root.speech-samples;+ sample-waves: root.speech-sample-waves;+ sample-details: root.speech-sample-details;closed => { root.speech-closed(); }text-edited(text) => { root.speech-text-edited(text); }voice-changed(index) => { root.speech-voice-changed(index); }model-changed(index) => { root.speech-model-changed(index); }- pace-changed(index) => { root.speech-pace-changed(index); }+ speed-changed(value) => { root.speech-speed-changed(value); }+ quality-changed(index) => { root.speech-quality-changed(index); }+ pauses-changed(value) => { root.speech-pauses-changed(value); }+ reference-start-changed(seconds) => { root.speech-reference-start-changed(seconds); }+ use-sample-changed(on) => { root.speech-use-sample-changed(on); }+ sample-changed(index) => { root.speech-sample-changed(index); }+ insert-tag(text, tag, at) => { return root.speech-insert-tag(text, tag, at); }begin => { root.speech-begin(); }cancel => { root.speech-cancel(); }}diff --git a/src/crates/concat/ui/dialogs/speech.slint b/src/crates/concat/ui/dialogs/speech.slintindex 1b808da9..224575dd 100644--- a/src/crates/concat/ui/dialogs/speech.slint+++ b/src/crates/concat/ui/dialogs/speech.slint@@ -7,14 +7,25 @@ import { Glyph, Icon } from "../icons.slint";import { Button, CopyChip, DialogRow, DialogSection, Modal, Progress } from "../primitives/modal.slint";import { SegmentedControl } from "../primitives/segmented-control.slint";import { Select } from "../primitives/select.slint";+import { Rail } from "../inspector/controls.slint";+import { Wave } from "../primitives/wave.slint";+import { Fmt } from "../util.slint";// Text to speech: what the tray's Speak tool and File › Text to speech open.//// A text box, a voice and a button is enough to send a job and not enough to-// get the read you wanted, so the three things that change a read are on the-// surface: which voice, which model, and the pace. Opened from a title the-// script is the title's words; opened from the menu it is whatever you type.-// While it runs the sheet is the progress report, with a clock beside it.+// get the read you wanted, so what changes a read is on the surface. The+// model comes first, because it decides the rest: which voices there are to+// choose from, and which dials the engine will read. Each model gets its own+// controls rather than the few every model shares - Kokoro its speed and its+// pauses, Pocket those and a quality, Chatterbox its expression tags and+// nothing about pace, since it reads at its own. The two that read in a+// recording can read in a sample voice instead of a named one: a section of+// its own, switched on at its header, offering the bin's recordings by their+// waveforms and how far into the chosen one the speaking starts. Opened+// from a title the script is the title's words; opened from the menu it is+// whatever you type. While it runs the sheet is the progress report, with a+// clock beside it.export struct SpeechSheetData {open: bool,@@ -23,8 +34,27 @@ export struct SpeechSheetData {voice: int,/// Row in the installed voice model list.model: int,- /// 0 Slower, 1 Natural, 2 Faster- pace: int,+ /// 0 Kokoro, 1 Pocket TTS, 2 Chatterbox: which controls the model has.+ family: int,+ /// The rate, 0.5..2; 1 is the voice's own. Kokoro and Pocket.+ speed: float,+ /// 0 quick, 1 balanced, 2 fine: Pocket's flow steps.+ quality: int,+ /// The breath between sentences, 0..1. Kokoro and Pocket.+ pauses: float,+ /// The model reads in a recording, so a sample voice can be offered:+ /// Pocket and Chatterbox.+ samples-offered: bool,+ /// Reading in a sample from the bin rather than a named voice.+ use-sample: bool,+ /// Row in the sample list.+ sample: int,+ /// The chosen sample's name, or empty when the bin has none.+ sample-name: string,+ /// How long that sample is, in seconds: the room the start below has.+ reference-length: float,+ /// Seconds into that sample the speaking starts.+ reference-start: float,running: bool,/// 0..1, as sentences complete.progress: float,@@ -38,17 +68,176 @@ export struct SpeechSheetData {message: string,}+// A list of recordings to pick a voice from, each drawn as its waveform+// with its name and length beside it - a voice is heard, and a row of+// names would say nothing about which one is the clean take. The shape is+// the Select's: a trigger showing the current row, a list under it that+// closes on a click outside. Without the Select's keyboard, since the+// rows are pictures and there are seldom more than a handful.+component SamplePicker inherits Rectangle {+ in property <[string]> names;+ /// Each recording's envelope as path commands; shorter than `names`+ /// is fine, and an empty one draws no wave.+ in property <[string]> waves;+ in property <[string]> details;+ in-out property <int> current;++ callback changed(index: int);++ property <length> row-h: 36px;+ property <length> content-h: root.names.length * root.row-h + 8px;+ property <length> list-h: Math.min(4 * root.row-h + 8px, root.content-h);+ property <bool> has-current: root.current >= 0 && root.current < root.names.length;++ height: 34px;+ horizontal-stretch: 1;+ border-radius: Theme.r;+ background: (list.is-open || trigger.has-hover) ? Theme.field-hover : Theme.field;++ animate background { duration: 120ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }++ HorizontalLayout {+ padding-left: 8px;+ padding-right: 6px;+ spacing: 8px;++ Rectangle {+ width: 96px;+ if root.has-current && root.current < root.waves.length: Wave {+ x: 0;+ y: 6px;+ width: parent.width;+ height: parent.height - 12px;+ commands: root.waves[root.current];+ tint: Theme.kind-audio;+ }+ }++ Text {+ horizontal-stretch: 1;+ text: root.has-current ? root.names[root.current] : I18n.t("Pick a recording");+ color: root.has-current ? Theme.fg : Theme.fg-dim;+ font-size: Theme.fs;+ vertical-alignment: center;+ overflow: elide;+ }++ VerticalLayout {+ alignment: center;+ Icon { glyph: Glyph.chevron-down; size: 12px; tint: Theme.fg-muted; }+ }+ }++ trigger := TouchArea {+ mouse-cursor: pointer;+ clicked => { list.show(); }+ }++ list := PopupWindow {+ x: 0;+ y: root.height + 4px;+ width: root.width;+ height: root.list-h;+ close-policy: close-on-click-outside;++ Rectangle {+ background: Theme.raised;+ border-width: 1px;+ border-color: Theme.line-strong;+ border-radius: Theme.r;+ clip: true;++ Flickable {+ viewport-height: root.content-h;++ VerticalLayout {+ padding: 4px;+ alignment: start;++ for name[index] in root.names: Rectangle {+ height: root.row-h;+ border-radius: Theme.r-sm;+ background: index == root.current ? Theme.accent-soft+ : pick.has-hover ? Theme.field+ : Colors.transparent;++ HorizontalLayout {+ padding-left: 6px;+ padding-right: 8px;+ spacing: 8px;++ Rectangle {+ width: 96px;+ if index < root.waves.length: Wave {+ x: 0;+ y: 6px;+ width: parent.width;+ height: parent.height - 12px;+ commands: root.waves[index];+ tint: Theme.kind-audio;+ }+ }++ Text {+ horizontal-stretch: 1;+ text: name;+ color: index == root.current ? Theme.fg : Theme.fg-muted;+ font-size: Theme.fs;+ vertical-alignment: center;+ overflow: elide;+ }++ if index < root.details.length: Text {+ text: root.details[index];+ color: Theme.fg-dim;+ font-family: Theme.font-technical;+ font-size: Theme.fs-sm;+ vertical-alignment: center;+ }+ }++ pick := TouchArea {+ mouse-cursor: pointer;+ clicked => {+ root.current = index;+ root.changed(index);+ list.close();+ }+ }+ }+ }+ }+ }+ }+}+export component SpeechDialog inherits Modal {in property <SpeechSheetData> data;in property <[string]> models;+ /// "Built-in speakers · fast", beside each model.+ in property <[string]> model-details;in property <[string]> voices;/// "American · female", beside each voice.in property <[string]> voice-details;+ /// The bin's recordings a voice can be taken from: their names, their+ /// envelopes as path commands, and their lengths.+ in property <[string]> samples;+ in property <[string]> sample-waves;+ in property <[string]> sample-details;callback text-edited(text: string);callback voice-changed(index: int);callback model-changed(index: int);- callback pace-changed(index: int);+ callback speed-changed(value: float);+ callback quality-changed(index: int);+ callback pauses-changed(value: float);+ callback reference-start-changed(seconds: float);+ callback use-sample-changed(on: bool);+ callback sample-changed(index: int);+ /// `tag` written into `text` at byte offset `at`, spaced as a word of+ /// its own. Rust does the writing: the expression language has no way+ /// to cut a string at an offset.+ pure callback insert-tag(text: string, tag: string, at: int) -> string;callback begin();callback cancel();@@ -68,12 +257,33 @@ export component SpeechDialog inherits Modal {/// The script has the caret. Kept up here because the box lives under/// an `if`, and nothing outside one can reach into it.property <bool> typing;+ // The sliders' own copies, seeded the same way: a Rail writes to the+ // property it is bound to, which drops the binding, so each is reseeded+ // from the data whenever it changes - and Rust echoes every change+ // back, so the reseed is the value the slider just set.+ property <float> speed-v;+ property <float> pauses-v;+ property <float> reference-start-v;changed data => {if (!root.typing) {root.draft = root.data.text;}+ root.speed-v = root.data.speed;+ root.pauses-v = root.data.pauses;+ root.reference-start-v = root.data.reference-start;}- init => { root.draft = root.data.text; }+ init => {+ root.draft = root.data.text;+ root.speed-v = root.data.speed;+ root.pauses-v = root.data.pauses;+ root.reference-start-v = root.data.reference-start;+ }+ /// A sample is wanted and the bin has one to give; a read without one+ /// would fail on its first step.+ property <bool> has-reference: !root.data.use-sample || root.data.sample-name != "";+ /// There is a voice to read with: a sample, or a named one on the list.+ /// Chatterbox names none until Pocket's recordings are on disk.+ property <bool> has-voice: root.data.use-sample || root.voices.length > 0;/// Seconds since the run began; the reference beside the bar.property <int> elapsed;@@ -135,6 +345,35 @@ export component SpeechDialog inherits Modal {}}+ // Chatterbox alone reads these as what they say, so the row is+ // its alone. Each lands at the caret as a word of its own, and+ // the caret moves past it, so a laugh can be dropped mid-line+ // without leaving the keyboard for long.+ if root.data.family == 2: HorizontalLayout {+ spacing: 6px;+ alignment: start;++ Text {+ text: I18n.t("Expression");+ color: Theme.fg-muted;+ font-size: Theme.fs;+ vertical-alignment: center;+ }++ for tag in ["[laugh]", "[chuckle]", "[sigh]"]: Button {+ label: tag;+ ghost: true;+ clicked => {+ let at = script.cursor-position-byte-offset;+ root.draft = root.insert-tag(root.draft, tag, at);+ root.text-edited(root.draft);+ script.focus();+ script.set-selection-offsets(at + tag.character-count + 1,+ at + tag.character-count + 1);+ }+ }+ }+Text {text: root.data.estimate;color: Theme.fg-dim;@@ -146,33 +385,111 @@ export component SpeechDialog inherits Modal {if !root.running: DialogSection {title: I18n.t("Voice");+ // The model first: it decides which voices there are and which+ // of the dials below are shown.DialogRow {+ label: I18n.t("Model");+ Select {+ options: root.models;+ details: root.model-details;+ current: root.data.model;+ placeholder: I18n.t("None installed");+ enabled: root.models.length > 0;+ changed(index) => { root.model-changed(index); }+ }+ }++ // The named voices, while a sample is not standing in for them.+ if !root.data.use-sample: DialogRow {label: I18n.t("Voice");Select {options: root.voices;details: root.voice-details;current: root.data.voice;+ placeholder: I18n.t("None");+ enabled: root.voices.length > 0;changed(index) => { root.voice-changed(index); }}}- DialogRow {- label: I18n.t("Model");- Select {- options: root.models;- current: root.data.model;- placeholder: I18n.t("None installed");- enabled: root.models.length > 0;- changed(index) => { root.model-changed(index); }+ // Chatterbox ships no recording of anyone's, so its named voices+ // are Pocket's two, borrowed while Pocket is on disk. With+ // neither there is nothing to read with but a sample.+ if root.data.family == 2 && root.voices.length == 0 && !root.data.use-sample: Text {+ text: I18n.t("Chatterbox has no voice of its own. Turn on Use sample voice below, or download Pocket TTS in Settings › Speech to borrow its two recordings.");+ color: Theme.danger;+ font-size: Theme.fs-sm;+ wrap: word-wrap;+ }++ // What this model is, in a line, so the dials under it are not+ // a surprise: a model that is missing one has never had it.+ if root.data.ready: Text {+ text: root.data.family == 0+ ? I18n.t("Speakers built into the model, in English and Chinese. Reads at the speed and with the pauses set below.")+ : root.data.family == 1+ ? I18n.t("Reads in any voice from a few seconds of a recording: one it ships with, or a sample from the bin.")+ : I18n.t("The closest to a studio voice. Reads at its own pace, in one of Pocket's two recordings or in any sample from the bin, and reads [laugh], [chuckle] and [sigh] as what they say.");+ color: Theme.fg-dim;+ font-size: Theme.fs-sm;+ wrap: word-wrap;+ }++ // Speed and pauses are sherpa's dials, and Chatterbox is not+ // sherpa's: it reads at its own pace, and a slider it would+ // ignore is a lie.+ if root.data.family != 2: DialogRow {+ label: I18n.t("Speed");+ Rail {+ value <=> root.speed-v;+ minimum: 0.5;+ maximum: 2;+ step: 0.05;+ default-value: 1;+ changed(v) => { root.speed-changed(v); }+ }+ Text {+ width: 52px;+ text: "\{Fmt.round-to(root.speed-v, 2)}×";+ color: Theme.fg-muted;+ font-family: Theme.font-technical;+ font-size: Theme.fs-sm;+ vertical-alignment: center;+ horizontal-alignment: right;}}- DialogRow {- label: I18n.t("Pace");+ if root.data.family != 2: DialogRow {+ label: I18n.t("Pauses");+ Rail {+ value <=> root.pauses-v;+ minimum: 0;+ maximum: 1;+ step: 0.05;+ default-value: 0.2;+ changed(v) => { root.pauses-changed(v); }+ }+ Text {+ width: 52px;+ text: root.pauses-v < 0.1 ? I18n.t("none")+ : root.pauses-v < 0.35 ? I18n.t("natural")+ : root.pauses-v < 0.7 ? I18n.t("long")+ : I18n.t("longer");+ color: Theme.fg-muted;+ font-family: Theme.font-technical;+ font-size: Theme.fs-sm;+ vertical-alignment: center;+ horizontal-alignment: right;+ }+ }++ // Pocket's flow steps: fewer is quicker, more is cleaner.+ if root.data.family == 1: DialogRow {+ label: I18n.t("Quality");SegmentedControl {- options: [I18n.t("Slower"), I18n.t("Natural"), I18n.t("Faster")];- current: root.data.pace;- changed(index) => { root.pace-changed(index); }+ options: [I18n.t("Quick"), I18n.t("Balanced"), I18n.t("Fine")];+ current: root.data.quality;+ changed(index) => { root.quality-changed(index); }}}@@ -184,6 +501,60 @@ export component SpeechDialog inherits Modal {}}+ // A sample voice: a recording from the bin in place of a named+ // voice, for the two models that read in one. The switch is at the+ // section's head, and the body folds away while it is off. The+ // recordings are offered by their waveforms, since a voice is heard+ // and not read, and the start slider says where in the recording+ // the model listens from.+ if !root.running && root.data.samples-offered: DialogSection {+ title: I18n.t("Use sample voice");+ switchable: true;+ on: root.data.use-sample;+ open: root.data.use-sample;+ switched(on) => { root.use-sample-changed(on); }+ hint: I18n.t("Reads in the voice heard in a recording from the bin. The first ten seconds from the point chosen below are what the model listens to.");++ if root.samples.length == 0: Text {+ text: I18n.t("Import a clip with a voice in it first.");+ color: Theme.fg-muted;+ font-size: Theme.fs-sm;+ wrap: word-wrap;+ }++ if root.samples.length > 0: DialogRow {+ label: I18n.t("Sample");+ SamplePicker {+ names: root.samples;+ waves: root.sample-waves;+ details: root.sample-details;+ current: root.data.sample;+ changed(index) => { root.sample-changed(index); }+ }+ }++ if root.samples.length > 0: DialogRow {+ label: I18n.t("Voice from");+ Rail {+ value <=> root.reference-start-v;+ minimum: 0;+ maximum: Math.max(0, root.data.reference-length - 1);+ step: 0.5;+ default-value: 0;+ changed(v) => { root.reference-start-changed(v); }+ }+ Text {+ width: 52px;+ text: I18n.t1("{0} s in", "\{Fmt.round-to(root.reference-start-v, 1)}");+ color: Theme.fg-muted;+ font-family: Theme.font-technical;+ font-size: Theme.fs-sm;+ vertical-alignment: center;+ horizontal-alignment: right;+ }+ }+ }+Rectangle {height: 1px;background: Theme.line;@@ -269,7 +640,7 @@ export component SpeechDialog inherits Modal {large: true;glyph: Glyph.volume;label: I18n.t("Generate speech");- enabled: root.data.ready && root.data.text != "";+ enabled: root.data.ready && root.data.text != "" && root.has-reference && root.has-voice;clicked => { root.begin(); }}}diff --git a/src/crates/concat/ui/primitives/modal.slint b/src/crates/concat/ui/primitives/modal.slintindex 3c0e1abc..60a045a1 100644--- a/src/crates/concat/ui/primitives/modal.slint+++ b/src/crates/concat/ui/primitives/modal.slint@@ -344,6 +344,15 @@ export component DialogSection inherits VerticalLayout {/// a question mark beside the title: read on hover, out of the way/// otherwise.in property <string> hint;+ /// A switch at the header's far end, for a group that is a feature to+ /// turn on rather than a set of settings that are always there. The+ /// switch draws `on` and reports a press through `switched`; it keeps+ /// no state of its own, so the caller's data stays the one truth and+ /// a reopened sheet cannot disagree with it. Bind `open` to the same+ /// value to fold the body away while it is off.+ in property <bool> switchable;+ in property <bool> on;+ callback switched(on: bool);if !root.first: Rectangle {height: 1px;@@ -422,6 +431,37 @@ export component DialogSection inherits VerticalLayout {vertical-alignment: center;overflow: elide;}++ // The same pill as the inspector's Switch, drawn from `on`+ // rather than holding a checked state of its own.+ if root.switchable: VerticalLayout {+ alignment: center;++ Rectangle {+ width: 30px;+ height: 17px;+ border-radius: self.height / 2;+ background: root.on ? Theme.accent : Theme.field-active;++ animate background { duration: 120ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }++ Rectangle {+ x: root.on ? parent.width - self.width - 2px : 2px;+ y: (parent.height - self.height) / 2;+ width: 13px;+ height: 13px;+ border-radius: self.width / 2;+ background: Theme.on-accent;++ animate x { duration: 120ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }+ }++ TouchArea {+ mouse-cursor: pointer;+ clicked => { root.switched(!root.on); }+ }+ }+ }}}