diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 1ec5996d..166907a1 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -6059,6 +6059,159 @@ def page(folder): check("the naming is logged, never a name", lines and not any(name in line for line in lines for name in ("Sarah", "équipe", "Camille")), lines) +def speakers_by_line(now: dt.datetime) -> None: + """DJ. D131, #1230's S2: each line of a complete transcript says who spoke, named by the user. Its speaker, a button + on the line, opens « Qui parle sur cette ligne ? »: a name given to this line alone gives it a voice of the + person's own (`transcript/v1`'s `voice` and `given`, #1244), its name in `speakers.json`'s `voices`; « Toutes les + lignes de cette voix » names every line of it; Escape closes it as it was; a blank name is said under the field, + what was typed kept; the field stays when the window comes back. Each line's speaker follows its line in the + order of Tab (D62). By keyboard alone; axe on the open field. No name is logged.""" + print("DJ. each line of a transcript named by the user: one line, or a voice everywhere (D131)") + meetings = WORK / "speakers-by-line" + meeting = meetings / "2026-11-30_14-00" + session(meeting, now - dt.timedelta(hours=2), 1, {}, form="v3") + # A sound that plays, as AB's: each line a button in the order of Tab, one at a time (D26, D62). + with wave.open(str(meeting / "local.wav"), "wb") as made: + made.setparams((2, 3, 48000, 0, "NONE", "not compressed")) + made.writeframes(bytes(6 * 48000 * 10)) + (meeting / "clock.jsonl").write_text('{"track":"local","sample":0,"at":0.0}\n') + record = json.loads((meeting / "session.json").read_text()) + (meeting / "session.json").write_text(json.dumps(record | {"tracks": {"local": {"device": "Mic"}}})) + current = meeting / "transcript.jsonl" + current.write_text( + '{"type":"header","contract":"transcript/v1","engine":"whisper.cpp","model":"m","language":null,"context":null}\n' + '{"type":"segment","speaker":"me","track":"local","voice":null,"start":0.0,"end":1.0,"text":"On commence."}\n' + '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":1.5,"end":3.0,"text":"Les tests passent."}\n' + '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":3.5,"end":5.0,"text":"Je confirme pour la 2.4."}\n' + '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":5.5,"end":7.0,"text":"Et la démo vendredi."}\n' + '{"type":"complete","duration":7.0}\n') + whos = "return [...document.querySelectorAll('#meeting .transcript .lines .who')].map(w => w.textContent.trim())" + held = lambda: [json.loads(line) for line in current.read_text().splitlines() if line.strip()] + voices = lambda: (json.loads((meeting / "speakers.json").read_text()) if (meeting / "speakers.json").is_file() else {}).get("voices") + panel_open = lambda b: bool(b.find_elements(By.ID, "voice-name")) + window = Window(meetings, "fr_FR.UTF-8", 'after = "nothing"\nreminder = false\n') + with window as browser: + def page(): + browser.execute_script("location.hash = '#/'") + wait_for(browser, lambda b: not b.find_elements(By.ID, "meeting"), 5) + browser.execute_script("location.hash = arguments[0]", f"#/meeting/{meeting.name}") + return wait_for(browser, lambda b: b.execute_script( + "return document.querySelectorAll('#meeting .transcript .lines .who').length") > 0, 15) + + # Each line's speaker by its id, never a reference held across a redraw: absent, None. + def who(index): + found = browser.execute_script("return [...document.querySelectorAll('#meeting .transcript .lines .who')].map(w => w.id)") + return found[index] if index < len(found) and found[index] else None + + def focused_on(index): + return who(index) is not None and browser.execute_script("return document.activeElement?.id") == who(index) + + def name(index, typed, everywhere=False, key=Keys.ENTER): + """Line `index`'s speaker by keyboard alone: focused, Enter, the scope chosen, the name typed, `key`.""" + if who(index) is None: + return False + browser.execute_script("document.getElementById(arguments[0]).focus()", who(index)) + ActionChains(browser).send_keys(Keys.ENTER).perform() + if not wait_for(browser, panel_open, 5): + return False + if everywhere and browser.find_elements(By.ID, "voice-all"): + browser.execute_script("document.getElementById('voice-all').click(); document.getElementById('voice-name').focus()") + field = browser.find_element(By.ID, "voice-name") + field.send_keys(Keys.CONTROL, "a") + field.send_keys(typed) + ActionChains(browser).send_keys(key).perform() + # A name the meeting already holds is offered under the field: the first Enter takes the suggestion, as a + # combobox's does (APG), the next one saves. + if not wait_for(browser, lambda b: not panel_open(b), 1.5) and panel_open(browser): + ActionChains(browser).send_keys(key).perform() + return wait_for(browser, lambda b: not panel_open(b), 5) + + page() + tags = browser.execute_script("return [...document.querySelectorAll('#meeting .transcript .lines .who')].map(w => w.tagName)") + check("each line's speaker is a button, its side as the page says it", + browser.execute_script(whos) == ["Vous", "Les autres", "Les autres", "Les autres"] and set(tags) == {"BUTTON"}, + [browser.execute_script(whos), tags]) + if who(2) is not None: + browser.execute_script("document.getElementById(arguments[0]).focus()", who(2)) + ActionChains(browser).send_keys(Keys.ENTER).perform() + opened = wait_for(browser, panel_open, 5) + got = browser.execute_script( + "const f = document.getElementById('voice-name'); return f ? [document.activeElement.id, f.labels[0]?.textContent.trim()," + " document.getElementById('voice-line')?.checked, document.getElementById(arguments[0] ?? '')?.getAttribute('aria-expanded')] : null", who(2)) + check("Enter on a line's speaker opens « Qui parle sur cette ligne ? », its field focused and labelled, « Cette ligne seulement » chosen", + opened and got == ["voice-name", "Qui parle sur cette ligne\u202f?", True, "true"], got) + violations = axe_violations(browser) if opened else [("the field absent", None, 0, [])] + check("axe: the open field, WCAG 2.2 A and AA, no violation", violations == [], violations) + typed = "return document.getElementById('voice-name')?.value ?? null" + said_now = "const s = document.getElementById('voice-said'); return s && !s.hidden ? s.textContent : ''" + # Nothing but spaces: said under the field, what was typed kept, nothing written. + ActionChains(browser).send_keys(" ").perform() + ActionChains(browser).send_keys(Keys.ENTER).perform() + shown = wait_for(browser, lambda b: b.execute_script(said_now), 5) + check("a blank name: « Saisissez un nom, ou appuyez sur Échap pour annuler. » under the field, what was typed kept, nothing written", + shown and browser.execute_script(said_now) == "Saisissez un nom, ou appuyez sur Échap pour annuler." + and browser.execute_script(typed) == " " and all("given" not in line for line in held()) and voices() is None, + [browser.execute_script(said_now), browser.execute_script(typed), voices()]) + browser.execute_script("document.getElementById('voice-name')?.select()") + ActionChains(browser).send_keys("Personne").perform() + # Back to the window while typing (window.js's focus draws the page anew): the field and what is typed stay. + browser.execute_script("window.dispatchEvent(new Event('focus'))") + time.sleep(1.5) + check("back to the window while naming: the field stays, what was typed kept", + browser.execute_script(typed) == "Personne", browser.execute_script(typed)) + if browser.find_elements(By.ID, "voice-name"): + browser.execute_script("document.getElementById('voice-name').focus()") + ActionChains(browser).send_keys(Keys.ESCAPE).perform() + closed = wait_for(browser, lambda b: not panel_open(b), 5) + check("Escape closes it as it was: nothing written, the focus back on the line's speaker", + closed and all("given" not in line for line in held()) and voices() is None + and focused_on(2), + [closed, voices(), browser.execute_script("return document.activeElement?.className")]) + + # Criterion 1: one line named, that line alone. + done = name(2, "Maya") + lines = held() + check("a name given to one line: that line alone takes it, its voice the person's own (#1), given the instant", + done and browser.execute_script(whos) == ["Vous", "Les autres", "Maya", "Les autres"] + and [line.get("voice") for line in lines[1:5]] == [None, None, "#1", None] + and bool(lines[3].get("given")) and voices() == {"remote/#1": "Maya"}, + [browser.execute_script(whos), [line.get("voice") for line in lines[1:5]], voices()]) + check("saved: the focus back on that line's speaker", focused_on(2), browser.execute_script("return document.activeElement?.id")) + named = browser.execute_script("return document.getElementById(arguments[0] ?? '')?.getAttribute('aria-label') ?? null", who(2)) + check("its accessible name holds the name shown, then what pressing it does (WCAG 2.5.3)", + named == "Maya\u00a0: changer qui parle à 00:03", named) + # D62's order of Tab: one line in it, its speaker with it; the arrows move both. + tabs = ("return [...document.querySelectorAll('#meeting .transcript .lines li')].map(l => [l.getAttribute('role'), l.tabIndex," + " l.querySelector('button.who')?.tabIndex])") + rows = browser.execute_script(tabs) + browser.execute_script("document.querySelector('#meeting .transcript .lines li[tabindex=\"0\"]')?.focus()") + ActionChains(browser).send_keys(Keys.ARROW_DOWN).perform() + moved = browser.execute_script(tabs) + check("each line's speaker follows its line in the order of Tab, one line at a time, the arrows moving both (D62)", + bool(rows) and all(role == "button" for role, *_ in rows) and all(line == who_ for _, line, who_ in rows) + and [line for _, line, _ in rows].count(0) == 1 and all(line == who_ for _, line, who_ in moved) and moved != rows, + [rows, moved]) + + done = name(3, "Maya") + check("the same name on another line is the same voice", + done and [line.get("voice") for line in held()[1:5]] == [None, None, "#1", "#1"] + and browser.execute_script(whos) == ["Vous", "Les autres", "Maya", "Maya"], browser.execute_script(whos)) + + # Criterion 2: a voice named, every line of it. + done = name(3, "Maya Durand", everywhere=True) + check("« Toutes les lignes de cette voix »: every line of it takes the name, the others as they were", + done and browser.execute_script(whos) == ["Vous", "Les autres", "Maya Durand", "Maya Durand"] + and voices() == {"remote/#1": "Maya Durand"}, [browser.execute_script(whos), voices()]) + page() + check("read again with the meeting: the names stay", + browser.execute_script(whos) == ["Vous", "Les autres", "Maya Durand", "Maya Durand"], browser.execute_script(whos)) + logs = WORK / "state" / "kitokey" / "logs" + logged = [line for log in sorted(logs.glob("*.jsonl")) for line in log.read_text().splitlines()] + given = [line for line in logged if "shell.voice_given" in line] + check("each naming is logged, never a name", len(given) >= 3 and not any(n in line for line in logged for n in ("Maya", "Sarah", "Personne")), + [len(given), [line for line in logged if any(n in line for n in ("Maya", "Sarah", "Personne"))][:3]]) + + def example_tried(now: dt.datetime) -> None: """CR. D126: « Essayer sur un exemple » from the empty window. The example of the window's language, bundled with Kitokey, is placed as a meeting of its own — its two tracks, its title saying it is an example — and runs @@ -18223,6 +18376,7 @@ def aside(folder): confidential_sent(now) example_tried(now) speakers_named(now) + speakers_by_line(now) waveform_drawn(now) settings_version(now) settings_narrow_without_model(now) diff --git a/modules/shell/src/correction.rs b/modules/shell/src/correction.rs index 75cf59ea..0c1a2f8f 100644 --- a/modules/shell/src/correction.rs +++ b/modules/shell/src/correction.rs @@ -28,7 +28,7 @@ pub fn tidy(text: &str) -> Option { } /// The speaker a track's segments are written under (`transcript/v1`). -fn speaker(track: &str) -> &'static str { +pub(crate) fn speaker(track: &str) -> &'static str { if track == "local" { "me" } else { "others" } } @@ -73,7 +73,7 @@ pub fn correct(file: &Path, track: &str, start: f64, text: &str, when: &str) -> } /// Writes `content` beside `file`, then renames it over: read at any moment, the file is whole. -fn replace(file: &Path, content: &str) -> io::Result<()> { +pub(crate) fn replace(file: &Path, content: &str) -> io::Result<()> { let beside = file.with_extension("jsonl.part"); let written = fs::write(&beside, content).and_then(|()| fs::rename(&beside, file)); if written.is_err() { diff --git a/modules/shell/src/lib.rs b/modules/shell/src/lib.rs index efa6570f..91380bc2 100644 --- a/modules/shell/src/lib.rs +++ b/modules/shell/src/lib.rs @@ -43,4 +43,5 @@ pub mod spoken; pub mod summarising; pub mod transcription; pub mod trial; +pub mod voices; pub mod words; diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index d044cd62..d6e6f113 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -50,7 +50,7 @@ use kitokey_shell::{ spoken, summarising::{self, Summarising}, transcription::{self, Hearer, Made, Transcription}, - trial, + trial, voices, words::{self, Failure, Language, Notice, Refusal, Told, Trouble}, }; @@ -436,6 +436,8 @@ fn main() { summary_sent, transcript_redo, transcript_corrected, + line_named, + voice_named, transcript_asked, example_tried, transcript_again, @@ -1800,6 +1802,8 @@ struct Opened { /// The names the user gave its two sides (#1205); none where the meeting cannot hold them — before /// session-audio/v3 —: the page then offers no naming. speakers: Option, + /// The voices a person gave lines, keyed `/`: their names (D131). + voices: std::collections::BTreeMap, /// The last transcript a redo replaced, the same way (D113). previous_transcript: Option, /// The summary shown was made on the other version of the transcript, not the one shown (#1070): @@ -1935,6 +1939,7 @@ fn opened(shell: State<'_, Shell>, name: String) -> Result { _ => None, }, speakers: speakers::offered(&folder).then(|| SpeakersShown::from(speakers::read(&folder))), + voices: speakers::voices(&folder), previous_transcript: match meeting::previous(&folder) { Read::Present(kept) => Some(Previous { made: kept.made, @@ -1967,6 +1972,47 @@ fn speakers_named(shell: State<'_, Shell>, name: String, me: Option, oth Ok(SpeakersShown::from(kept)) } +/// Who spoke on one line of a meeting's transcript, named on the user's word (D131): that line alone given a voice +/// of the person's own when `everywhere` is false, else every line of its voice. Once complete, never while it is +/// made, waits to be made again or its minutes are written — as a correction (D62). No name is logged. +fn voice_given(shell: &Shell, name: &str, track: &str, start: f64, who: &str, everywhere: bool) -> Result<(), Told> { + let folder = session_folder(shell, name)?; + let running = shell.transcription.lock().unwrap(); + let hearing = shell.hearing.lock().unwrap().as_deref() == Some(folder.as_path()); + let waits = shell.waiting.lock().unwrap().iter().any(|(queued, ..)| *queued == folder); + if (running.is_some() && hearing) || waits { + return Err(shell.told(Failure::Busy, format!("the transcript of {name} is being made"))); + } + if shell.writing_minutes.lock().unwrap().as_deref() == Some(folder.as_path()) { + return Err(shell.told(Failure::Busy, format!("the minutes of {name} are being written"))); + } + let when = chrono::Local::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, false); + let given = if everywhere { + voices::voice_named(&folder, track, start, who, &when) + } else { + voices::line_named(&folder, track, start, who, &when).map(|_| ()) + }; + given.map_err(|refused| match refused { + voices::Refused::NotComplete => shell.told(Failure::NotComplete, format!("the transcript of {name} is not complete")), + voices::Refused::NoSuchLine => shell.told(Failure::Unexpected, "no line of the transcript starts there"), + voices::Refused::Name | voices::Refused::NotOffered => shell.told(Failure::Unexpected, "a name or a meeting the page never offers"), + voices::Refused::File(why) => shell.told(Failure::MeetingFile, why), + })?; + drop(running); + tracing::info!(track, everywhere, "shell.voice_given"); + Ok(()) +} + +#[tauri::command] +fn line_named(shell: State<'_, Shell>, name: String, track: String, start: f64, who: String) -> Result<(), Told> { + voice_given(&shell, &name, &track, start, &who, false) +} + +#[tauri::command] +fn voice_named(shell: State<'_, Shell>, name: String, track: String, start: f64, who: String) -> Result<(), Told> { + voice_given(&shell, &name, &track, start, &who, true) +} + /// The steps whose own model a meeting chose and cannot have now (D91). fn gone_of(settings: &Settings, folder: &Path) -> Vec { let chosen = meeting_models::read(folder); diff --git a/modules/shell/src/speakers.rs b/modules/shell/src/speakers.rs index 213709e0..be3b5baa 100644 --- a/modules/shell/src/speakers.rs +++ b/modules/shell/src/speakers.rs @@ -1,9 +1,10 @@ //! The names a person gives a meeting's speakers (#1205): `speakers.json` of `contracts/session-audio/v3`, written by //! the shell on the user's word and read by it and by `summary`. Without a producer that tells voices apart, the shell //! names the two sides alone — `me`, the local track, where it says « Vous », and `others`, the remote one, where it -//! says « Les autres » —; `voices` it never writes, and keeps as it found them. +//! says « Les autres » —. `voices` it writes for a voice a person gave (D131, `voices.rs`), and keeps the others as it +//! found them. -use std::{fs, io, path::Path}; +use std::{collections::BTreeMap, fs, io, path::Path}; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; @@ -30,7 +31,7 @@ impl Speakers { } /// A name as the contract allows it: one line, 1 to 60 characters, not blank. -fn allowed(name: &str) -> bool { +pub fn allowed(name: &str) -> bool { !name.trim().is_empty() && name.chars().count() <= LONGEST && !name.contains(['\n', '\r']) } @@ -95,11 +96,16 @@ pub fn write(folder: &Path, wanted: &Speakers) -> io::Result { None => object.remove(key), }; } + save(folder, object).map(|()| kept) +} + +/// The file written whole — beside, then renamed —; an empty object, no file. +fn save(folder: &Path, object: Map) -> io::Result<()> { let target = folder.join(FILE); if object.is_empty() { return match fs::remove_file(&target) { Err(error) if error.kind() != io::ErrorKind::NotFound => Err(error), - _ => Ok(kept), + _ => Ok(()), }; } let beside = folder.join(".speakers.json.part"); @@ -108,5 +114,32 @@ pub fn write(folder: &Path, wanted: &Speakers) -> io::Result { if written.is_err() { let _ = fs::remove_file(&beside); } - written.map(|()| kept) + written +} + +/// The voices' names the meeting holds, keyed `/`: each the contract allows, else absent. +pub fn voices(folder: &Path) -> BTreeMap { + let held = object_of(folder).and_then(|mut object| object.remove("voices")); + let Some(Value::Object(voices)) = held else { + return BTreeMap::new(); + }; + voices + .into_iter() + .filter_map(|(key, name)| match name { + Value::String(name) if allowed(&name) && key.contains('/') => Some((key, name)), + _ => None, + }) + .collect() +} + +/// A voice's name written, keyed `/`, whatever else the file holds kept. The caller has trimmed it +/// and checked the contract allows it. +pub fn voice_written(folder: &Path, key: &str, name: &str) -> io::Result<()> { + let mut object = object_of(folder).unwrap_or_default(); + let voices = object.entry("voices").or_insert_with(|| Value::Object(Map::new())); + if !voices.is_object() { + *voices = Value::Object(Map::new()); + } + voices[key] = Value::String(name.to_string()); + save(folder, object) } diff --git a/modules/shell/src/voices.rs b/modules/shell/src/voices.rs new file mode 100644 index 00000000..0b60a3b6 --- /dev/null +++ b/modules/shell/src/voices.rs @@ -0,0 +1,172 @@ +//! D131: each line of a transcript says who spoke, named by the user (#1230's S2). `transcript/v1`'s « a voice +//! given » (#1244): once complete, the shell sets one segment's `voice` to a label of the person's own — starting with +//! `#` — and its `given` to when, the file replaced whole; the label's name is kept in `speakers.json`'s `voices` +//! (`session-audio/v3`). No voice's sound is ever measured. + +use std::path::Path; + +use serde_json::Value; + +use crate::{correction, speakers}; + +/// The transcript's name, in the meeting's folder. +pub const TRANSCRIPT: &str = "transcript.jsonl"; + +/// Why a name is not given. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Refused { + /// No `complete` line: the transcript is still made, or was stopped. + NotComplete, + /// No segment of that track starts there. + NoSuchLine, + /// A name the contract refuses: blank, over 60 characters, a line break. + Name, + /// A meeting before `session-audio/v3`, which holds no names. + NotOffered, + /// The file could not be read or written. + File(String), +} + +fn file_error(error: impl ToString) -> Refused { + Refused::File(error.to_string()) +} + +/// A transcript as its lines, each kept as written, and each parsed. +struct Lines { + raw: Vec, + parsed: Vec>, +} + +impl Lines { + fn read(file: &Path) -> Result { + let text = std::fs::read_to_string(file).map_err(file_error)?; + let raw: Vec = text.split_inclusive('\n').map(str::to_string).collect(); + let parsed = raw.iter().map(|line| serde_json::from_str(line.trim_end()).ok()).collect(); + Ok(Lines { raw, parsed }) + } + + fn complete(&self) -> bool { + self.parsed.iter().flatten().any(|value| value["type"] == "complete") + } + + /// Each segment, by its index among the lines. + fn segments(&self) -> impl Iterator { + self.parsed + .iter() + .enumerate() + .filter_map(|(at, value)| value.as_ref().filter(|value| value["type"] == "segment").map(|value| (at, value))) + } + + /// The segment of `track` that starts at `start`, to the hundredth: a segment is known by its speaker and start. + fn find(&self, track: &str, start: f64) -> Option { + let speaker = correction::speaker(track); + self.segments() + .find(|(_, value)| value["speaker"] == speaker && value["start"].as_f64().is_some_and(|at| (at - start).abs() < 0.005)) + .map(|(at, _)| at) + } + + /// Segment `at` given `voice` at `given`, its line written anew, every other field as it was. + fn set(&mut self, at: usize, voice: Value, given: &str) { + if let Some(value) = self.parsed[at].as_mut() { + value["voice"] = voice; + value["given"] = Value::String(given.to_string()); + self.raw[at] = format!("{value}\n"); + } + } + + fn write(&self, file: &Path) -> Result<(), Refused> { + correction::replace(file, &self.raw.concat()).map_err(file_error) + } +} + +/// A segment's track: its own, else its speaker's (`transcript/v1`). +fn track_of(segment: &Value) -> &str { + segment["track"] + .as_str() + .unwrap_or(if segment["speaker"] == "me" { "local" } else { "remote" }) +} + +/// What every naming checks first, in this order: the meeting holds names, the name is one the contract allows, the +/// transcript is complete and holds that line. Nothing is written before. +fn ready(folder: &Path, track: &str, start: f64, name: &str) -> Result<(Lines, usize, String), Refused> { + if !speakers::offered(folder) { + return Err(Refused::NotOffered); + } + let name = name.trim(); + if !speakers::allowed(name) { + return Err(Refused::Name); + } + let lines = Lines::read(&folder.join(TRANSCRIPT))?; + if !lines.complete() { + return Err(Refused::NotComplete); + } + let at = lines.find(track, start).ok_or(Refused::NoSuchLine)?; + Ok((lines, at, name.to_string())) +} + +/// The person's label for `name` on `track`: the one already named so, else the next `#n` neither the names nor the +/// transcript use. +fn label_for(folder: &Path, lines: &Lines, track: &str, name: &str) -> String { + let names = speakers::voices(folder); + let prefix = format!("{track}/"); + if let Some(key) = names + .iter() + .find(|(key, named)| key.starts_with(&prefix) && named.as_str() == name) + .map(|(key, _)| key) + { + return key[prefix.len()..].to_string(); + } + let number = |label: &str| label.strip_prefix('#').and_then(|n| n.parse::().ok()); + let in_names = names.keys().filter_map(|key| key.strip_prefix(&prefix)).filter_map(number); + let in_lines = lines + .segments() + .filter(|(_, segment)| track_of(segment) == track) + .filter_map(|(_, segment)| segment["voice"].as_str().and_then(number)); + format!("#{}", in_names.chain(in_lines).max().unwrap_or(0) + 1) +} + +/// The line of `track` starting at `start` given to `name`, it alone: a label of the person's own, `given` set to +/// `when`, the name kept with it. The label is returned. +pub fn line_named(folder: &Path, track: &str, start: f64, name: &str, when: &str) -> Result { + let (mut lines, at, name) = ready(folder, track, start, name)?; + let label = label_for(folder, &lines, track, &name); + speakers::voice_written(folder, &format!("{track}/{label}"), &name).map_err(file_error)?; + lines.set(at, Value::String(label.clone()), when); + lines.write(&folder.join(TRANSCRIPT))?; + Ok(label) +} + +/// The voice of the line of `track` starting at `start` named `name`, every line of it: a voice of the person's own, +/// its name; a voice not told, its side's (#1205); a producer's label, a label of the person's own given first to each +/// of its lines — a producer's label holds within one transcript only (`transcript/v1`). +pub fn voice_named(folder: &Path, track: &str, start: f64, name: &str, when: &str) -> Result<(), Refused> { + let (mut lines, at, name) = ready(folder, track, start, name)?; + let voice = lines.parsed[at] + .as_ref() + .and_then(|segment| segment["voice"].as_str().map(str::to_string)); + match voice { + None => { + let mut sides = speakers::read(folder); + if track == "local" { + sides.me = Some(name); + } else { + sides.others = Some(name); + } + speakers::write(folder, &sides).map(|_| ()).map_err(file_error) + } + Some(label) if label.starts_with('#') => speakers::voice_written(folder, &format!("{track}/{label}"), &name).map_err(file_error), + Some(told) => { + let label = label_for(folder, &lines, track, &name); + speakers::voice_written(folder, &format!("{track}/{label}"), &name).map_err(file_error)?; + let same: Vec = lines + .segments() + .filter(|(_, segment)| track_of(segment) == track && segment["voice"].as_str() == Some(told.as_str())) + .map(|(at, _)| at) + .collect(); + for at in same { + lines.set(at, Value::String(label.clone()), when); + } + lines.write(&folder.join(TRANSCRIPT)) + } + } +} diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index 6395cebe..4bb6d3f4 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -751,6 +751,25 @@ pub struct Window { /// Shows: a meeting's page, as an error under the fields, what was typed kept. When: the names could not be /// kept in the meeting's folder. At most: one line. Placeholders: none. pub speakers_not_saved: &'static str, + /// Who spoke on one line, named by the user (D131): the speaker's button on each line, its name and tooltip. + /// Shows: a meeting's page, as a button's name. When: a complete transcript of a v3 meeting. At most: one line. + /// Placeholders: {} who speaks there now, {} the line's time. + pub who_change: &'static str, + /// Shows: a meeting's page, as a field's label. When: a line's speaker being named. At most: about 30 + /// characters. Placeholders: none. + pub who_field: &'static str, + /// Shows: a meeting's page, as a choice. When: a line's speaker being named, the name for that line alone. + /// At most: about 25 characters. Placeholders: none. + pub who_line_only: &'static str, + /// Shows: a meeting's page, as a choice. When: a line's speaker being named, the name for every line of its + /// voice. At most: about 35 characters. Placeholders: none. + pub who_everywhere: &'static str, + /// Shows: a meeting's page, as an error under the field, what was typed kept. When: a line's speaker named with + /// nothing but spaces. At most: one line. Placeholders: none. + pub who_empty: &'static str, + /// Shows: a meeting's page, as an error under the field, what was typed kept. When: the name could not be kept. + /// At most: one line. Placeholders: {} why, as the shell says it. + pub who_failed: &'static str, /// Who spoke over the meeting, for whoever does not see the drawing. /// Shows: a meeting's page, as a name for a screen reader. When: screen reader: the /// speaking-time drawing. At most: no limit. Placeholders: none. @@ -2317,6 +2336,12 @@ pub fn window(language: Language) -> Window { speakers_cancel: "Cancel", speakers_hint: "Kept with this meeting. Leave a field empty to keep “You” or “Others”.", speakers_not_saved: "Kitokey could not save these names. Try again.", + who_change: "{}: change who speaks at {}", + who_field: "Who speaks on this line?", + who_line_only: "This line only", + who_everywhere: "Every line of this voice", + who_empty: "Type a name, or press Escape to cancel.", + who_failed: "Name not saved: {}", who_spoke: "Who spoke when: you on top, others below", who_spoke_later: "Who spoke when appears once it is transcribed.", no_transcript: "No transcript yet.", @@ -2925,6 +2950,12 @@ pub fn window(language: Language) -> Window { speakers_cancel: "Annuler", speakers_hint: "Gardés avec cette réunion. Laissez un champ vide pour garder «\u{a0}Vous\u{a0}» ou «\u{a0}Les autres\u{a0}».", speakers_not_saved: "Kitokey n’a pas pu enregistrer ces noms. Réessayez.", + who_change: "{}\u{a0}: changer qui parle à {}", + who_field: "Qui parle sur cette ligne\u{202f}?", + who_line_only: "Cette ligne seulement", + who_everywhere: "Toutes les lignes de cette voix", + who_empty: "Saisissez un nom, ou appuyez sur Échap pour annuler.", + who_failed: "Nom non enregistré\u{a0}: {}", who_spoke: "Temps de parole au fil de la réunion\u{a0}: vous en haut, les autres en bas", who_spoke_later: "Le temps de parole s’affichera après la transcription.", no_transcript: "Pas encore de transcription.", diff --git a/modules/shell/tests/voices.rs b/modules/shell/tests/voices.rs new file mode 100644 index 00000000..a929a735 --- /dev/null +++ b/modules/shell/tests/voices.rs @@ -0,0 +1,188 @@ +//! D131: each line of a transcript says who spoke, named by the user (#1230's S2, `transcript/v1`'s « a voice given », +//! #1244, #1251). A name given to one line gives that line alone a voice of the person's own — a label starting with +//! `#`, its `given` the instant —, the name kept in `speakers.json`'s `voices` (`session-audio/v3`); a name given to a +//! voice names every line of that voice. + +use std::{fs, path::Path}; + +use kitokey_shell::voices::{self, Refused}; +use serde_json::{Value, json}; + +const HEADER: &str = r#"{"type":"header","contract":"transcript/v1","engine":"whisper.cpp","model":"m","language":null,"context":null}"#; + +fn segment(speaker: &str, track: &str, start: f64, end: f64, text: &str) -> String { + json!({"type": "segment", "speaker": speaker, "track": track, "voice": null, "start": start, "end": end, "text": text}).to_string() +} + +/// Four lines: one of « Vous », three of the call, and the `complete` line when `complete`. +fn transcript(complete: bool) -> String { + let mut lines = vec![ + HEADER.to_string(), + segment("me", "local", 0.0, 1.0, "On commence."), + segment("others", "remote", 1.5, 3.0, "Les tests passent."), + segment("others", "remote", 3.5, 5.0, "Je confirme pour la 2.4."), + segment("others", "remote", 5.5, 7.0, "Et la démo vendredi."), + ]; + if complete { + lines.push(r#"{"type":"complete","duration":7.0}"#.to_string()); + } + lines.iter().map(|line| format!("{line}\n")).collect() +} + +fn meeting(contract: &str, complete: bool) -> tempfile::TempDir { + let folder = tempfile::tempdir().unwrap(); + fs::write( + folder.path().join("session.json"), + format!(r#"{{"contract":"{contract}","started":"2026-11-30T14:05:00+01:00","stopped":"2026-11-30T14:35:00+01:00","tracks":{{}}}}"#), + ) + .unwrap(); + fs::write(folder.path().join("transcript.jsonl"), transcript(complete)).unwrap(); + folder +} + +fn lines(folder: &Path) -> Vec { + fs::read_to_string(folder.join("transcript.jsonl")) + .unwrap() + .lines() + .map(|line| serde_json::from_str(line).unwrap()) + .collect() +} + +fn speakers(folder: &Path) -> Value { + fs::read(folder.join("speakers.json")) + .ok() + .and_then(|bytes| serde_json::from_slice(&bytes).ok()) + .unwrap_or(Value::Null) +} + +const WHEN: &str = "2026-11-30T15:00:00+01:00"; +const LATER: &str = "2026-11-30T15:05:00+01:00"; + +#[test] +fn a_name_given_to_one_line_gives_that_line_alone_a_voice_of_the_person_s_own() { + let folder = meeting("session-audio/v3", true); + let before = lines(folder.path()); + let label = voices::line_named(folder.path(), "remote", 3.5, " Maya ", WHEN); + assert_eq!(label, Ok("#1".to_string())); + let after = lines(folder.path()); + assert_eq!(after.len(), before.len(), "the lines in the same order, none added"); + for (at, (was, now)) in before.iter().zip(&after).enumerate() { + if at == 3 { + let mut expected = was.clone(); + expected["voice"] = json!("#1"); + expected["given"] = json!(WHEN); + assert_eq!(now, &expected, "the line named: its voice and given alone"); + } else { + assert_eq!(now, was, "line {at} as it was"); + } + } + assert_eq!(speakers(folder.path()), json!({"voices": {"remote/#1": "Maya"}})); + // Written whole: nothing left beside. + let left: Vec<_> = fs::read_dir(folder.path()).unwrap().map(|e| e.unwrap().file_name()).collect(); + assert_eq!(left.len(), 3, "{left:?}"); +} + +#[test] +fn the_same_name_on_another_line_of_the_track_is_the_same_voice_another_name_a_new_one() { + let folder = meeting("session-audio/v3", true); + assert_eq!(voices::line_named(folder.path(), "remote", 1.5, "Maya", WHEN), Ok("#1".to_string())); + assert_eq!(voices::line_named(folder.path(), "remote", 5.5, "Maya", WHEN), Ok("#1".to_string())); + assert_eq!( + voices::line_named(folder.path(), "remote", 3.5, "Karim", LATER), + Ok("#2".to_string()) + ); + let voices_of: Vec = lines(folder.path()) + .iter() + .skip(1) + .take(4) + .map(|line| line["voice"].clone()) + .collect(); + assert_eq!(voices_of, vec![Value::Null, json!("#1"), json!("#2"), json!("#1")]); + assert_eq!( + speakers(folder.path()), + json!({"voices": {"remote/#1": "Maya", "remote/#2": "Karim"}}) + ); +} + +#[test] +fn a_name_given_to_a_voice_names_every_line_of_it_the_transcript_unchanged() { + let folder = meeting("session-audio/v3", true); + voices::line_named(folder.path(), "remote", 1.5, "Maya", WHEN).unwrap(); + voices::line_named(folder.path(), "remote", 5.5, "Maya", WHEN).unwrap(); + let before = fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(); + assert_eq!(voices::voice_named(folder.path(), "remote", 5.5, "Maya Durand", LATER), Ok(())); + assert_eq!(fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(), before); + assert_eq!(speakers(folder.path()), json!({"voices": {"remote/#1": "Maya Durand"}})); +} + +#[test] +fn a_name_given_to_a_voice_not_told_names_its_side_as_before() { + let folder = meeting("session-audio/v3", true); + fs::write(folder.path().join("speakers.json"), r#"{"me":"Sarah"}"#).unwrap(); + let before = fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(); + assert_eq!(voices::voice_named(folder.path(), "remote", 3.5, "L’équipe produit", WHEN), Ok(())); + assert_eq!(fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(), before); + assert_eq!(speakers(folder.path()), json!({"me": "Sarah", "others": "L’équipe produit"})); +} + +#[test] +fn a_voice_a_producer_told_is_given_a_label_of_the_person_s_own_on_each_of_its_lines() { + let folder = meeting("session-audio/v3", true); + let told: String = transcript(true) + .lines() + .map(|line| { + let mut value: Value = serde_json::from_str(line).unwrap(); + if value["track"] == "remote" && value["start"] != json!(3.5) { + value["voice"] = json!("2"); + } + format!("{value}\n") + }) + .collect(); + fs::write(folder.path().join("transcript.jsonl"), told).unwrap(); + assert_eq!(voices::voice_named(folder.path(), "remote", 1.5, "Maya", WHEN), Ok(())); + let after = lines(folder.path()); + let given: Vec<(Value, Value)> = after + .iter() + .skip(1) + .take(4) + .map(|line| (line["voice"].clone(), line["given"].clone())) + .collect(); + assert_eq!( + given, + vec![ + (Value::Null, Value::Null), + (json!("#1"), json!(WHEN)), + (Value::Null, Value::Null), + (json!("#1"), json!(WHEN)), + ], + "the producer's label `2` never named: each of its lines given `#1`" + ); + assert_eq!(speakers(folder.path()), json!({"voices": {"remote/#1": "Maya"}})); +} + +#[test] +fn a_name_is_refused_before_complete_on_no_line_blank_too_long_or_before_v3_nothing_written() { + let cases: [(&str, bool, &str, f64, &str, Refused); 5] = [ + ("session-audio/v3", false, "remote", 3.5, "Maya", Refused::NotComplete), + ("session-audio/v3", true, "remote", 9.0, "Maya", Refused::NoSuchLine), + ("session-audio/v3", true, "remote", 3.5, " ", Refused::Name), + ("session-audio/v3", true, "remote", 3.5, &"x".repeat(61), Refused::Name), + ("session-audio/v2", true, "remote", 3.5, "Maya", Refused::NotOffered), + ]; + for (contract, complete, track, start, name, refused) in cases { + let folder = meeting(contract, complete); + let before = fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(); + assert_eq!( + voices::line_named(folder.path(), track, start, name, WHEN), + Err(refused.clone()), + "{contract} {name}" + ); + assert_eq!( + voices::voice_named(folder.path(), track, start, name, WHEN), + Err(refused), + "{contract} {name}" + ); + assert_eq!(fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(), before); + assert!(!folder.path().join("speakers.json").exists()); + } +} diff --git a/modules/shell/ui/window.css b/modules/shell/ui/window.css index 9715be55..74e79747 100644 --- a/modules/shell/ui/window.css +++ b/modules/shell/ui/window.css @@ -141,6 +141,11 @@ mark { background: var(--mark); color: var(--mark-ink); box-shadow: inset 0 -2px .speakers-panel { margin: 8px 0 12px; } .speakers-panel > .note, .speakers-choices { flex-basis: 100%; margin: 0; } .speakers-choices { display: flex; gap: 8px; } +/* D131: a line's speaker, a button that reads as its name; its field under the line. */ +button.who { align-self: flex-start; padding: 0; border: 0; background: none; font-family: inherit; line-height: inherit; cursor: pointer; } +button.who:hover { text-decoration: underline; } +.voice-panel { cursor: auto; } +.voice-scope { display: flex; flex-wrap: wrap; flex-basis: 100%; gap: var(--sp-1) var(--sp-4); } .send-said:empty { display: none; } .sends { list-style: none; margin: 4px 0 0; padding: 0; color: var(--soft); font-size: 13px; } .sends:empty { display: none; } diff --git a/modules/shell/ui/window.js b/modules/shell/ui/window.js index df773632..0445833e 100644 --- a/modules/shell/ui/window.js +++ b/modules/shell/ui/window.js @@ -2895,6 +2895,9 @@ function roam(lines, line) { // Its pencil follows it in the order of Tab: one line, one pencil reached by Tab (D62). const pencil = other.querySelector(".edit"); if (pencil) pencil.tabIndex = other.tabIndex; + // And its speaker's button (D131). + const who = other.querySelector("button.who"); + if (who) who.tabIndex = other.tabIndex; } } @@ -2926,10 +2929,119 @@ function tookAndCost(read, words) { // Who said a line, as the page names them: the track — by the name the user gave its side (#1205), else the // page's word —, and the voice within it when one was told. function whoSaid(segment, words, names) { + // A voice a person gave the line, by its name (D131). + const given = names?.voices?.[`${segment.track}/${segment.voice}`]; + if (given) return given; const side = segment.track === "local" ? names?.me ?? words.here : names?.others ?? words.remote; return segment.voice === null ? side : `${side} · ${fill(words.voice, segment.voice)}`; } +// A line's speaker said: its words, and on its button (D131) the name that says what pressing it does. +function sayWho(who, segment, words, names) { + who.textContent = whoSaid(segment, words, names); + if (who.tagName !== "BUTTON") return; + who.setAttribute("aria-label", fill(words.who_change, who.textContent, clock(segment.start))); + who.title = who.getAttribute("aria-label"); +} + +// Who speaks on one line, named by the user (D131), in a field under it: that line alone, or every line of its voice +// (Fireflies', Otter's two scopes). Enter saves, Escape or « Annuler » closes it as it was, the focus back on the +// line's speaker; a name not kept is said under the field, what was typed kept. The names offered are the meeting's. +function whoPanel(card, read, segment, who, words, session, names) { + // One at a time: another line's closes. + document.getElementById("voice-panel")?.remove(); + for (const open of card.querySelectorAll("button.who[aria-expanded=true]")) open.setAttribute("aria-expanded", "false"); + const panel = element("form", "fields speakers-panel voice-panel"); + panel.id = "voice-panel"; + panel.setAttribute("aria-label", words.who_field); + const close = () => { + panel.remove(); + who.setAttribute("aria-expanded", "false"); + who.focus(); + }; + const [row, input] = guidedField("voice-name", words.who_field, "text", "", false); + input.maxLength = 60; + input.autocomplete = "off"; + input.placeholder = who.textContent; + const known = element("datalist"); + known.id = "voice-names"; + for (const name of new Set([names.me, names.others, ...Object.values(names.voices ?? {})].filter(Boolean))) { + const option = element("option"); + option.value = name; + known.append(option); + } + input.setAttribute("list", "voice-names"); + const scope = element("div", "voice-scope"); + const choice = (id, text, checked) => { + const label = element("label", "choice"); + const radio = element("input"); + radio.type = "radio"; + radio.name = "voice-scope"; + radio.id = id; + radio.checked = checked; + label.append(radio, element("span", "", text)); + scope.append(label); + return radio; + }; + choice("voice-line", words.who_line_only, true); + const everywhere = choice("voice-all", words.who_everywhere, false); + const said = element("p", "note warn", ""); + said.id = "voice-said"; + said.setAttribute("role", "alert"); + said.hidden = true; + const save = element("button", "primary", words.speakers_save); + save.type = "submit"; + save.id = "voice-save"; + const cancel = element("button", "", words.speakers_cancel); + cancel.type = "button"; + cancel.id = "voice-cancel"; + cancel.addEventListener("click", close); + const choices = element("div", "speakers-choices"); + choices.append(save, cancel); + panel.append(row, known, scope, said, choices); + // Its own keys and clicks: never the line's, which plays the meeting from it. + for (const kind of ["click", "keydown"]) panel.addEventListener(kind, (event) => event.stopPropagation()); + panel.addEventListener("keydown", (event) => { + if (event.key !== "Escape") return; + event.preventDefault(); + close(); + }); + panel.addEventListener("submit", async (event) => { + event.preventDefault(); + // Nothing but spaces: said under the field, what was typed kept, nothing asked of the shell. + if (input.value.trim() === "") { + said.textContent = words.who_empty; + said.hidden = false; + return input.focus(); + } + save.disabled = true; + try { + const asked = { name: nameOf(session), track: segment.track, start: segment.start, who: input.value }; + await window.__TAURI__.core.invoke(everywhere.checked ? "voice_named" : "line_named", asked); + // The names and voices as the meeting now holds them: every line, and what a copy takes, says them. + const now = await window.__TAURI__.core.invoke("opened", { name: nameOf(session) }); + Object.assign(names, now.speakers ?? {}, { voices: now.voices ?? {} }); + const fresh = now.transcript.state === "present" ? now.transcript.segments : []; + const lines = card.querySelectorAll(".lines li"); + read.segments.forEach((one, index) => { + const same = fresh[index]; + if (same && same.track === one.track && same.start === one.start) one.voice = same.voice; + const shown = lines[index]?.querySelector(".who"); + if (shown) sayWho(shown, one, words, names); + }); + close(); + } catch (why) { + said.textContent = fill(words.who_failed, why); + said.hidden = false; + } finally { + save.disabled = false; + } + }); + who.closest(".said").append(panel); + who.setAttribute("aria-expanded", "true"); + input.focus(); +} + // The button that opens the speakers' names, and its panel under the card's top (#1205): Enter saves, Escape or // « Annuler » closes it as it was; a name refused or not kept is said under the fields, what was typed kept. function speakersButton(card, names, read, words, session) { @@ -2990,7 +3102,7 @@ function speakersButton(card, names, read, words, session) { const lines = card.querySelectorAll(".lines li"); read.segments.forEach((segment, index) => { const who = lines[index]?.querySelector(".who"); - if (who) who.textContent = whoSaid(segment, words, names); + if (who) sayWho(who, segment, words, names); }); close(); } catch { @@ -3007,9 +3119,10 @@ function speakersButton(card, names, read, words, session) { return open; } -function transcriptCard(read, words, session, onPage, previous, speakers) { - // The sides' names as kept (#1205): none where the meeting cannot hold them; renamed in place below. - const names = speakers ? { ...speakers } : null; +function transcriptCard(read, words, session, onPage, previous, speakers, voices) { + // The sides' names as kept (#1205), and the voices' a person gave lines (D131): none where the meeting cannot + // hold them; renamed in place below. + const names = speakers ? { ...speakers, voices: { ...(voices ?? {}) } } : null; const card = element("aside", "card transcript"); card.setAttribute("aria-label", words.transcript_title); const top = element("div", "top"); @@ -3133,7 +3246,27 @@ function transcriptCard(read, words, session, onPage, previous, speakers) { const who = whoSaid(segment, words, names); const said = element("div", "said"); const text = element("span", "text", segment.text); - said.append(element("span", `who ${segment.track}`, who), text); + // Its speaker, once complete in a meeting that holds names: a button that names who speaks there (D131). + const whoOf = element(read.complete && names ? "button" : "span", `who ${segment.track}`, who); + if (whoOf.tagName === "BUTTON") { + whoOf.type = "button"; + whoOf.id = `who-${segment.track}-${segment.start}`; + whoOf.setAttribute("aria-expanded", "false"); + whoOf.setAttribute("aria-controls", "voice-panel"); + whoOf.tabIndex = line.hasAttribute("role") ? line.tabIndex : 0; + sayWho(whoOf, segment, words, names); + whoOf.addEventListener("keydown", (event) => event.stopPropagation()); + whoOf.addEventListener("click", (event) => { + event.stopPropagation(); + if (whoOf.getAttribute("aria-expanded") === "true") { + document.getElementById("voice-panel")?.remove(); + whoOf.setAttribute("aria-expanded", "false"); + return; + } + whoPanel(card, read, segment, whoOf, words, session, names); + }); + } + said.append(whoOf, text); if (segment.edited) said.append(element("span", "edited", words.corrected)); line.append(element("span", "at", clock(segment.start)), said); // Corrected by whoever listens, once complete (D62): the line becomes a field; Enter or leaving @@ -3491,7 +3624,7 @@ function trashedFocused() { } } -function showMeeting({ session, transcript, minutes, developer, listen: listened, context, confidential, language, languages, meeting_language, apple, system_language, models_gone, previous_minutes, previous_transcript, minutes_other_version, speakers }, words) { +function showMeeting({ session, transcript, minutes, developer, listen: listened, context, confidential, language, languages, meeting_language, apple, system_language, models_gone, previous_minutes, previous_transcript, minutes_other_version, speakers, voices }, words) { const page = document.getElementById("meeting"); const top = element("div", "meeting-top"); const name = nameOf(session); @@ -3656,7 +3789,7 @@ function showMeeting({ session, transcript, minutes, developer, listen: listened // The models each line offers, read once for both (D93). const onPage = pageModels(session); meetingTabs(columns, nameOf(session), words, minutesCard(minutes, words, session, transcript, onPage, previous_minutes, minutes_other_version), - transcriptCard(transcript, words, session, onPage, previous_transcript, speakers), minutes.state !== "absent"); + transcriptCard(transcript, words, session, onPage, previous_transcript, speakers, voices), minutes.state !== "absent"); // Shown again when the window comes forward: a search in progress in this meeting is kept. const searching = page.dataset.name === nameOf(session) ? (document.getElementById("search")?.value ?? "") : ""; // A name being typed is kept the same way, with its refusal and where the caret was (D70). @@ -7270,7 +7403,9 @@ window.addEventListener("focus", () => { || document.querySelector("#settings:not([hidden]) #minutes-unsaved:not([hidden])") || [...document.querySelectorAll("#settings:not([hidden]) .fields input")].some((input) => input.value !== input.defaultValue) // The speakers being named (#1205): what is typed stays. - || document.getElementById("speakers-panel"); + || document.getElementById("speakers-panel") + // Or one line's speaker (D131). + || document.getElementById("voice-panel"); // Back from a list's menu, not from elsewhere: nothing drawn anew (#944). const menu = inMenu; inMenu = false;