Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d3e0add86 | ||
|
|
24cebd7e71 | ||
|
|
9e53d0b390 | ||
|
|
48000f47eb | ||
|
|
79e31d5331 | ||
|
|
20eb53af4b | ||
|
|
6183feaf82 |
Generated
+1
-1
@@ -445,7 +445,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "call-recorder"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"chrono",
|
||||
|
||||
@@ -179,14 +179,26 @@ pub struct CallDetail {
|
||||
/// Whether retention deleted the call's audio (as opposed to the files
|
||||
/// being missing for another reason).
|
||||
pub audio_deleted: bool,
|
||||
/// The call's language, or the last-used one for a call without its
|
||||
/// own yet ([`preselect_language`]): what the language picker next to
|
||||
/// "Transkribieren"/"Erneut versuchen" starts on.
|
||||
pub language: String,
|
||||
}
|
||||
|
||||
/// The language the picker starts on for `call`: the one it was
|
||||
/// transcribed in, else `last_used` (the settings' `language`).
|
||||
pub fn preselect_language(call: &Call, last_used: &str) -> String {
|
||||
call.language
|
||||
.clone()
|
||||
.unwrap_or_else(|| last_used.to_string())
|
||||
}
|
||||
|
||||
impl CallDetail {
|
||||
/// `segments` are the stored ones; `merges` the stored speaker merges
|
||||
/// (source key → target key); `backend_url` is this build's backend
|
||||
/// (see [`CallListItem::of`]); `language` is the call-language setting
|
||||
/// in effect now (not necessarily what the call was transcribed with),
|
||||
/// used to apply [`correct_segment_text`] to each segment's text —
|
||||
/// (see [`CallListItem::of`]); `last_used_language` is the settings'
|
||||
/// `language` (see [`preselect_language`]). The call's language picks
|
||||
/// the [`correct_segment_text`] applied to each segment's text —
|
||||
/// non-destructively, so it also corrects transcripts from before the
|
||||
/// correction existed.
|
||||
pub fn of(
|
||||
@@ -195,8 +207,11 @@ impl CallDetail {
|
||||
speaker_names: BTreeMap<String, String>,
|
||||
merges: &BTreeMap<String, String>,
|
||||
backend_url: &str,
|
||||
language: &str,
|
||||
last_used_language: &str,
|
||||
) -> Self {
|
||||
// A call with segments always has its language (see the store's
|
||||
// schema v5); the fallback only covers a call not transcribed yet.
|
||||
let language = preselect_language(call, last_used_language);
|
||||
let segments = merge::apply_merges(segments, merges)
|
||||
.iter()
|
||||
.map(|segment| SegmentView {
|
||||
@@ -204,7 +219,7 @@ impl CallDetail {
|
||||
label: merge::label(&segment.speaker, &speaker_names),
|
||||
start: segment.start,
|
||||
end: segment.end,
|
||||
text: correct_segment_text(&segment.text, language),
|
||||
text: correct_segment_text(&segment.text, &language),
|
||||
})
|
||||
.collect();
|
||||
Self {
|
||||
@@ -219,6 +234,7 @@ impl CallDetail {
|
||||
audio_available: false,
|
||||
audio_deleted: call.audio_deleted,
|
||||
speaker_names,
|
||||
language,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,6 +363,7 @@ mod tests {
|
||||
title: None,
|
||||
crm_transcript_id: None,
|
||||
crm_base_url: None,
|
||||
language: None,
|
||||
uploaded_at: None,
|
||||
}
|
||||
}
|
||||
@@ -657,19 +674,22 @@ mod tests {
|
||||
"uploading": false,
|
||||
"audio_available": false,
|
||||
"audio_deleted": false,
|
||||
"language": "de",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/// With German as the last-used language (what matters for a call
|
||||
/// without its own, see `CallDetail::of`).
|
||||
fn detail_with(c: &Call, segments: &[Segment], names: &[(&str, &str)]) -> CallDetail {
|
||||
detail_with_language(c, segments, names, "de")
|
||||
detail_last_used(c, segments, names, "de")
|
||||
}
|
||||
|
||||
fn detail_with_language(
|
||||
fn detail_last_used(
|
||||
c: &Call,
|
||||
segments: &[Segment],
|
||||
names: &[(&str, &str)],
|
||||
language: &str,
|
||||
last_used_language: &str,
|
||||
) -> CallDetail {
|
||||
CallDetail::of(
|
||||
c,
|
||||
@@ -677,7 +697,7 @@ mod tests {
|
||||
keys(names),
|
||||
&keys(&[("remote:2", "remote:1")]),
|
||||
BACKEND,
|
||||
language,
|
||||
last_used_language,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -757,14 +777,38 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn corrections_are_not_applied_outside_german_calls() {
|
||||
let c = call(Some(at(10, 15, 0)));
|
||||
let mut c = call(Some(at(10, 15, 0)));
|
||||
c.language = Some("en".into());
|
||||
let segments = [segment(Speaker::Me, 0.0, "Cheers!")];
|
||||
|
||||
let detail = detail_with_language(&c, &segments, &[], "en");
|
||||
// German was used last, but this call is English.
|
||||
let detail = detail_last_used(&c, &segments, &[], "de");
|
||||
|
||||
assert_eq!(detail.segments[0].text, "Cheers!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn corrections_follow_the_calls_language_not_the_last_used_one() {
|
||||
let mut c = call(Some(at(10, 15, 0)));
|
||||
c.language = Some("de".into());
|
||||
let segments = [segment(Speaker::Me, 0.0, "Cheers!")];
|
||||
|
||||
let detail = detail_last_used(&c, &segments, &[], "en");
|
||||
|
||||
assert_eq!(detail.segments[0].text, "Tschüss!");
|
||||
assert_eq!(detail.language, "de");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_preselected_language_is_the_calls_own_else_the_last_used() {
|
||||
let mut c = call(None);
|
||||
assert_eq!(preselect_language(&c, "fr"), "fr");
|
||||
|
||||
c.language = Some("it".into());
|
||||
assert_eq!(preselect_language(&c, "fr"), "it");
|
||||
assert_eq!(detail_last_used(&c, &[], &[], "fr").language, "it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_upload_text_uses_the_corrected_segment_text() {
|
||||
let c = call(Some(at(10, 46, 0)));
|
||||
|
||||
@@ -48,6 +48,9 @@ pub struct Call {
|
||||
pub crm_base_url: Option<String>,
|
||||
/// When the transcript was last uploaded.
|
||||
pub uploaded_at: Option<DateTime<Local>>,
|
||||
/// The language (ISO 639-1 code) the call is transcribed in, chosen
|
||||
/// when its transcription was started; `None` before that.
|
||||
pub language: Option<String>,
|
||||
}
|
||||
|
||||
/// A single transcribed word with its timing and speaker attribution.
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::transcribe::{TranscribeError, TranscribeOptions, Transcriber};
|
||||
/// Settings a pipeline run uses.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct PipelineOptions {
|
||||
/// ISO 639-1 code, or `"auto"`.
|
||||
/// The call's language, one of [`crate::settings::CALL_LANGUAGES`].
|
||||
pub language: String,
|
||||
pub deepscript_model: String,
|
||||
/// Custom words/names submitted with both tracks (DeepScript's
|
||||
|
||||
@@ -166,6 +166,7 @@ mod tests {
|
||||
title: None,
|
||||
crm_transcript_id: None,
|
||||
crm_base_url: None,
|
||||
language: None,
|
||||
uploaded_at: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ mod tests {
|
||||
title: None,
|
||||
crm_transcript_id: None,
|
||||
crm_base_url: None,
|
||||
language: None,
|
||||
uploaded_at: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,20 @@ pub const RETENTION_DAYS: RangeInclusive<u32> = 1..=3650;
|
||||
/// default on load (see [`Settings::load`]) rather than failing.
|
||||
pub const DEEPSCRIPT_MODELS: [&str; 2] = ["premium", "premium_jade"];
|
||||
|
||||
/// The languages (ISO 639-1) a call can be transcribed in, chosen per call
|
||||
/// when its transcription is started. All are in DeepScript's
|
||||
/// `GET /v1/languages`; its `"auto"` is not offered.
|
||||
pub const CALL_LANGUAGES: [&str; 5] = ["de", "en", "es", "fr", "it"];
|
||||
|
||||
/// Checks a call language chosen in the UI; the error is shown as is.
|
||||
pub fn check_call_language(language: &str) -> Result<(), String> {
|
||||
if CALL_LANGUAGES.contains(&language) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("Unbekannte Sprache: {language}"))
|
||||
}
|
||||
}
|
||||
|
||||
/// Default custom-vocabulary terms: short standalone German words/names
|
||||
/// DeepScript otherwise tends to mistranscribe or drop.
|
||||
const DEFAULT_VOCABULARY: [&str; 5] = ["Tschüss", "Perfekt", "Servus", "Moin", "Euvino"];
|
||||
@@ -56,6 +70,9 @@ pub struct Settings {
|
||||
pub allowlist: Vec<String>,
|
||||
pub mic_device: Option<String>,
|
||||
pub output_device: Option<String>,
|
||||
/// The language of the transcription started last (one of
|
||||
/// [`CALL_LANGUAGES`]), preselected for the next call. Set by the app
|
||||
/// when a transcription is started, not by the settings page.
|
||||
pub language: String,
|
||||
pub deepscript_model: String,
|
||||
/// Custom words/names submitted with every transcription (DeepScript's
|
||||
@@ -146,12 +163,14 @@ impl Settings {
|
||||
}
|
||||
|
||||
/// The settings after the user saved `edited` over these: normalized
|
||||
/// (see [`normalize_vocabulary`]), checked, with the backend login
|
||||
/// (which only the app changes) kept, so a settings page loaded before
|
||||
/// a login cannot undo it.
|
||||
/// (see [`normalize_vocabulary`]), checked, with the backend login and
|
||||
/// the last-used language (which only the app changes) kept, so a
|
||||
/// settings page loaded before a login or a transcription cannot undo
|
||||
/// them.
|
||||
pub fn edited(&self, mut edited: Settings) -> Result<Settings, String> {
|
||||
edited.vocabulary = normalize_vocabulary(edited.vocabulary);
|
||||
edited.validate()?;
|
||||
edited.language = self.language.clone();
|
||||
edited.backend_username = self.backend_username.clone();
|
||||
edited.backend_key_expires_at = self.backend_key_expires_at;
|
||||
edited.backend_key_base_url = self.backend_key_base_url.clone();
|
||||
@@ -162,8 +181,9 @@ impl Settings {
|
||||
/// defaults; fields missing from the file take their default value. A
|
||||
/// `deepscript_model` outside [`DEEPSCRIPT_MODELS`] (e.g. an older
|
||||
/// file's `"standard"`) falls back to the default instead of failing, and
|
||||
/// so does a `retention_days` outside [`RETENTION_DAYS`]; `vocabulary`
|
||||
/// is normalized (see [`normalize_vocabulary`]).
|
||||
/// so does a `retention_days` outside [`RETENTION_DAYS`] and a
|
||||
/// `language` outside [`CALL_LANGUAGES`]; `vocabulary` is normalized
|
||||
/// (see [`normalize_vocabulary`]).
|
||||
pub fn load(path: &Path) -> Settings {
|
||||
let mut settings: Settings = fs::read_to_string(path)
|
||||
.ok()
|
||||
@@ -172,6 +192,9 @@ impl Settings {
|
||||
if !DEEPSCRIPT_MODELS.contains(&settings.deepscript_model.as_str()) {
|
||||
settings.deepscript_model = Settings::default().deepscript_model;
|
||||
}
|
||||
if check_call_language(&settings.language).is_err() {
|
||||
settings.language = Settings::default().language;
|
||||
}
|
||||
// 0 would delete all audio on the next pass.
|
||||
if !RETENTION_DAYS.contains(&settings.retention_days) {
|
||||
settings.retention_days = Settings::default().retention_days;
|
||||
@@ -289,6 +312,51 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_five_call_languages_are_accepted() {
|
||||
for language in CALL_LANGUAGES {
|
||||
assert_eq!(check_call_language(language), Ok(()), "{language}");
|
||||
}
|
||||
assert_eq!(CALL_LANGUAGES, ["de", "en", "es", "fr", "it"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn another_call_language_is_refused() {
|
||||
assert_eq!(
|
||||
check_call_language("auto"),
|
||||
Err("Unbekannte Sprache: auto".to_string())
|
||||
);
|
||||
assert_eq!(
|
||||
check_call_language("pt"),
|
||||
Err("Unbekannte Sprache: pt".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unknown_stored_language_falls_back_to_the_default() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("settings.json");
|
||||
fs::write(&path, r#"{"language": "auto"}"#).unwrap();
|
||||
assert_eq!(Settings::load(&path).language, "de");
|
||||
|
||||
fs::write(&path, r#"{"language": "it"}"#).unwrap();
|
||||
assert_eq!(Settings::load(&path).language, "it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_edit_keeps_the_last_used_language_which_only_the_app_changes() {
|
||||
let current = Settings {
|
||||
language: "fr".into(),
|
||||
..Settings::default()
|
||||
};
|
||||
let edited = Settings {
|
||||
language: "de".into(),
|
||||
..Settings::default()
|
||||
};
|
||||
|
||||
assert_eq!(current.edited(edited).unwrap().language, "fr");
|
||||
}
|
||||
|
||||
fn logged_in() -> Settings {
|
||||
Settings {
|
||||
backend_username: Some("hinrichs".into()),
|
||||
|
||||
+101
-8
@@ -130,9 +130,25 @@ ALTER TABLE calls ADD COLUMN crm_base_url TEXT;
|
||||
UPDATE calls SET crm_base_url = 'https://test.euvinopro.eu' WHERE crm_transcript_id IS NOT NULL;
|
||||
";
|
||||
|
||||
/// Version 5: the language a call is transcribed in, chosen per call when
|
||||
/// its transcription is started. Before this version every transcription
|
||||
/// used the then default German: backfilled for the calls one was started
|
||||
/// for, so their corrections (`call_view`) stay as they were; a call still
|
||||
/// waiting gets its language when the user decides.
|
||||
const SCHEMA_V5_SQL: &str = "
|
||||
ALTER TABLE calls ADD COLUMN language TEXT;
|
||||
UPDATE calls SET language = 'de' WHERE status NOT IN ('recording', 'awaiting_decision');
|
||||
";
|
||||
|
||||
/// Schema steps by `PRAGMA user_version`: entry `i` takes a database from
|
||||
/// version `i` to `i + 1`. A new database runs all of them.
|
||||
const MIGRATIONS: &[&str] = &[SCHEMA_V1_SQL, SCHEMA_V2_SQL, SCHEMA_V3_SQL, SCHEMA_V4_SQL];
|
||||
const MIGRATIONS: &[&str] = &[
|
||||
SCHEMA_V1_SQL,
|
||||
SCHEMA_V2_SQL,
|
||||
SCHEMA_V3_SQL,
|
||||
SCHEMA_V4_SQL,
|
||||
SCHEMA_V5_SQL,
|
||||
];
|
||||
|
||||
/// SQLite-backed store for calls and everything derived from them.
|
||||
pub struct Store {
|
||||
@@ -390,6 +406,16 @@ impl Store {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the language (ISO 639-1 code) the call is transcribed in.
|
||||
pub fn set_language(&self, id: CallId, language: &str) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute(
|
||||
"UPDATE calls SET language = ?1 WHERE id = ?2",
|
||||
params![language, id],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn mark_transcribed(&self, id: CallId, at: DateTime<Local>) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute(
|
||||
@@ -549,9 +575,9 @@ fn ids_with_status(conn: &rusqlite::Connection, status: CallStatus) -> Result<Ve
|
||||
Ok(ids)
|
||||
}
|
||||
|
||||
const SELECT_ALL_CALLS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title, crm_transcript_id, uploaded_at, crm_base_url FROM calls";
|
||||
const SELECT_ALL_CALLS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title, crm_transcript_id, uploaded_at, crm_base_url, language FROM calls";
|
||||
|
||||
const SELECT_CALL_COLUMNS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title, crm_transcript_id, uploaded_at, crm_base_url FROM calls WHERE id = ?1";
|
||||
const SELECT_CALL_COLUMNS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title, crm_transcript_id, uploaded_at, crm_base_url, language FROM calls WHERE id = ?1";
|
||||
|
||||
fn row_to_call(row: &Row) -> Result<Call> {
|
||||
let id: CallId = row.get(0)?;
|
||||
@@ -569,6 +595,7 @@ fn row_to_call(row: &Row) -> Result<Call> {
|
||||
let crm_transcript_id: Option<String> = row.get(12)?;
|
||||
let uploaded_at: Option<String> = row.get(13)?;
|
||||
let crm_base_url: Option<String> = row.get(14)?;
|
||||
let language: Option<String> = row.get(15)?;
|
||||
|
||||
Ok(Call {
|
||||
id,
|
||||
@@ -586,6 +613,7 @@ fn row_to_call(row: &Row) -> Result<Call> {
|
||||
crm_transcript_id,
|
||||
crm_base_url,
|
||||
uploaded_at: opt_dt_from_str(uploaded_at)?,
|
||||
language,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -715,6 +743,14 @@ CREATE TABLE speaker_merges (
|
||||
const RELEASED_V3_STEP_SQL: &str = "
|
||||
ALTER TABLE calls ADD COLUMN crm_transcript_id TEXT;
|
||||
ALTER TABLE calls ADD COLUMN uploaded_at TEXT;
|
||||
";
|
||||
|
||||
/// The schema of user_version 4, exactly as release 0.2.2 created it
|
||||
/// (copied from `SCHEMA_V4_SQL` at `HEAD`): version 3 plus these
|
||||
/// statements.
|
||||
const RELEASED_V4_STEP_SQL: &str = "
|
||||
ALTER TABLE calls ADD COLUMN crm_base_url TEXT;
|
||||
UPDATE calls SET crm_base_url = 'https://test.euvinopro.eu' WHERE crm_transcript_id IS NOT NULL;
|
||||
";
|
||||
|
||||
fn user_version(path: &Path) -> i64 {
|
||||
@@ -738,7 +774,7 @@ ALTER TABLE calls ADD COLUMN uploaded_at TEXT;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_new_database_starts_at_version_4() {
|
||||
fn a_new_database_starts_at_version_5() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("calls.sqlite");
|
||||
let store = Store::open(&path).unwrap();
|
||||
@@ -750,7 +786,7 @@ ALTER TABLE calls ADD COLUMN uploaded_at TEXT;
|
||||
.unwrap();
|
||||
drop(store);
|
||||
|
||||
assert_eq!(user_version(&path), 4);
|
||||
assert_eq!(user_version(&path), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -807,7 +843,7 @@ ALTER TABLE calls ADD COLUMN uploaded_at TEXT;
|
||||
store.set_title(1, Some("Lieferung März")).unwrap();
|
||||
store.set_speaker_merge(1, "remote:2", "remote:1").unwrap();
|
||||
drop(store);
|
||||
assert_eq!(user_version(&path), 4);
|
||||
assert_eq!(user_version(&path), 5);
|
||||
let store = Store::open(&path).unwrap();
|
||||
let call = store.get_call(1).unwrap().unwrap();
|
||||
assert_eq!(call.title.as_deref(), Some("Lieferung März"));
|
||||
@@ -861,7 +897,7 @@ ALTER TABLE calls ADD COLUMN uploaded_at TEXT;
|
||||
.set_uploaded(1, "crm-1", "https://backend.example", uploaded)
|
||||
.unwrap();
|
||||
drop(store);
|
||||
assert_eq!(user_version(&path), 4);
|
||||
assert_eq!(user_version(&path), 5);
|
||||
let store = Store::open(&path).unwrap();
|
||||
let call = store.get_call(1).unwrap().unwrap();
|
||||
assert_eq!(call.crm_transcript_id.as_deref(), Some("crm-1"));
|
||||
@@ -915,7 +951,64 @@ ALTER TABLE calls ADD COLUMN uploaded_at TEXT;
|
||||
assert_eq!(not_uploaded.crm_transcript_id, None);
|
||||
assert_eq!(not_uploaded.crm_base_url, None);
|
||||
|
||||
assert_eq!(user_version(&path), 4);
|
||||
assert_eq!(user_version(&path), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_version_4_database_is_upgraded_backfilling_german_for_started_transcriptions() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("calls.sqlite");
|
||||
let started = "2026-11-05T10:14:00+01:00";
|
||||
{
|
||||
let conn = rusqlite::Connection::open(&path).unwrap();
|
||||
conn.execute_batch(RELEASED_V1_SCHEMA_SQL).unwrap();
|
||||
conn.execute_batch(RELEASED_V2_STEP_SQL).unwrap();
|
||||
conn.execute_batch(RELEASED_V3_STEP_SQL).unwrap();
|
||||
conn.execute_batch(RELEASED_V4_STEP_SQL).unwrap();
|
||||
conn.execute_batch("PRAGMA user_version = 4;").unwrap();
|
||||
for (app, status) in [
|
||||
("Microsoft Teams", "done"),
|
||||
("Zoom", "failed"),
|
||||
("MicroSIP", "awaiting_decision"),
|
||||
] {
|
||||
conn.execute(
|
||||
"INSERT INTO calls \
|
||||
(app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted) \
|
||||
VALUES (?1, ?2, ?2, ?3, 0, NULL, '/rec/mic.wav', '/rec/out.wav', NULL, 0)",
|
||||
rusqlite::params![app, started, status],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
let store = Store::open(&path).unwrap();
|
||||
|
||||
// Transcriptions started before this version all used the then
|
||||
// default German; a call still waiting has no language yet.
|
||||
let languages: Vec<_> = (1..=3)
|
||||
.map(|id| store.get_call(id).unwrap().unwrap().language)
|
||||
.collect();
|
||||
assert_eq!(
|
||||
languages,
|
||||
[Some("de".to_string()), Some("de".to_string()), None]
|
||||
);
|
||||
assert_eq!(user_version(&path), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_language_is_stored_per_call() {
|
||||
let store = Store::open_in_memory().unwrap();
|
||||
let id = new_call(&store);
|
||||
let other = new_call(&store);
|
||||
assert_eq!(store.get_call(id).unwrap().unwrap().language, None);
|
||||
|
||||
store.set_language(id, "fr").unwrap();
|
||||
|
||||
assert_eq!(
|
||||
store.get_call(id).unwrap().unwrap().language.as_deref(),
|
||||
Some("fr")
|
||||
);
|
||||
assert_eq!(store.get_call(other).unwrap().unwrap().language, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"version": "0.3.0",
|
||||
"pub_date": "2026-11-10T12:53:50Z",
|
||||
"version": "0.3.1",
|
||||
"pub_date": "2026-11-10T13:23:27Z",
|
||||
"platforms": {
|
||||
"windows-x86_64": {
|
||||
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVUdGpRa1ZvalU2SU9tSmFRMGJMRzZKblhYd0FDU0p6SFNsZ3NBSVUwRmdnbm5IZEUyeko2WHpjRFp3cFdqV2pZU3QxanllQUtIbEFJUkI3ZlJnV1lsRXY4TjlycGNMcEFrPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzk0MzE1MjAzCWZpbGU6R2VzcHLDpGNoc3Jla29yZGVyXzAuMy4wX3g2NC1zZXR1cC5leGUJdmVyc2lvbjowLjMuMApzUjBYdFFNN1hOT3p0NXVyZFpBcDB0NVJUaW5PcDdRS00yZk5COGJWYnZKbXVpQTBqVE43bjkzaU00c2hKQ1VHNFBZSUJIRVZHRkxjMTNDRkNzYktDdz09Cg==",
|
||||
"url": "https://gitea.euvino.eu/public/call-recorder/releases/download/v0.3.0/Gespraechsrekorder_0.3.0_x64-setup.exe"
|
||||
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVUdGpRa1ZvalU2SURncUNMNDdEMzVWc3pESHpGdFhHUmJVZVEvOWIxeTZjWWVKaTYvZmRRb0NqK1lpNzB6UDlPSy9lVjkvN2xOWXFFSCs5aUJLdGZhNnV2N2ZaM2Q1ZFFRPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzk0MzE2OTgwCWZpbGU6R2VzcHLDpGNoc3Jla29yZGVyXzAuMy4xX3g2NC1zZXR1cC5leGUJdmVyc2lvbjowLjMuMQozYnFtdGxXQlNkcCtTWHRGdFRhOE9xNnhBeDVLdE16cEp6allUYzNZU1Y5Q3JaUlc3V2o4WjV2OWZRNFRVVFJ2WitJUTVxZ3U5WkU3Umx6SS9Sb1REdz09Cg==",
|
||||
"url": "https://gitea.euvino.eu/public/call-recorder/releases/download/v0.3.1/Gespraechsrekorder_0.3.1_x64-setup.exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "call-recorder"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
description = "Gesprächsrekorder desktop app"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
@@ -250,16 +250,17 @@ pub async fn discard_call(app: AppHandle, id: CallId) -> CmdResult<()> {
|
||||
}
|
||||
|
||||
/// Transkribieren in the end-of-call prompt: starts processing in the
|
||||
/// background and returns at once; the call leaves the prompt.
|
||||
/// background in the chosen `language` and returns at once; the call
|
||||
/// leaves the prompt.
|
||||
#[tauri::command]
|
||||
pub async fn transcribe_call(app: AppHandle, id: CallId) -> CmdResult<()> {
|
||||
blocking(app, move |app| processing::start(app, id, false)).await
|
||||
pub async fn transcribe_call(app: AppHandle, id: CallId, language: String) -> CmdResult<()> {
|
||||
blocking(app, move |app| processing::start(app, id, false, language)).await
|
||||
}
|
||||
|
||||
/// Processes a failed (or still undecided) call again.
|
||||
/// Processes a failed (or still undecided) call again, in `language`.
|
||||
#[tauri::command]
|
||||
pub async fn retry_call(app: AppHandle, id: CallId) -> CmdResult<()> {
|
||||
blocking(app, move |app| processing::start(app, id, true)).await
|
||||
pub async fn retry_call(app: AppHandle, id: CallId, language: String) -> CmdResult<()> {
|
||||
blocking(app, move |app| processing::start(app, id, true, language)).await
|
||||
}
|
||||
|
||||
/// After a call left the prompt queue: hides the prompt if no call waits
|
||||
|
||||
@@ -9,6 +9,7 @@ use std::path::PathBuf;
|
||||
use recorder_core::model::{CallId, CallStatus};
|
||||
use recorder_core::pipeline::{self, PipelineOptions};
|
||||
use recorder_core::secrets::Service;
|
||||
use recorder_core::settings::check_call_language;
|
||||
use recorder_core::transcribe::deepscript::DeepScript;
|
||||
use recorder_core::transcribe::TranscribeError;
|
||||
use serde::Serialize;
|
||||
@@ -57,13 +58,22 @@ impl Drop for Claim {
|
||||
}
|
||||
}
|
||||
|
||||
/// Starts processing call `id` in the background and returns at once; the
|
||||
/// call leaves the end-of-call prompt. `retry` also allows failed calls.
|
||||
/// Without a DeepScript key nothing starts: the call is marked failed and
|
||||
/// the error returned. Reads the keyring, so call it off the UI thread.
|
||||
pub fn start(app: &AppHandle, id: CallId, retry: bool) -> Result<(), String> {
|
||||
/// Starts processing call `id` in `language` in the background and returns
|
||||
/// at once; the call leaves the end-of-call prompt. `retry` also allows
|
||||
/// failed calls. The language is stored with the call and remembered for
|
||||
/// the next one; one outside `CALL_LANGUAGES` is refused before anything
|
||||
/// changes. Without a DeepScript key nothing starts: the call is marked
|
||||
/// failed and the error returned. Reads the keyring, so call it off the UI
|
||||
/// thread.
|
||||
pub fn start(app: &AppHandle, id: CallId, retry: bool, language: String) -> Result<(), String> {
|
||||
check_call_language(&language)?;
|
||||
let claim = Claim::take(app, id, retry)?;
|
||||
let state = app.state::<AppState>();
|
||||
state
|
||||
.store
|
||||
.set_language(id, &language)
|
||||
.map_err(|e| format!("Interner Fehler: {e}"))?;
|
||||
state.remember_language(&language);
|
||||
|
||||
let Some(key) = deepscript_key(&state) else {
|
||||
let msg = TranscribeError::MissingKey.user_message();
|
||||
@@ -76,7 +86,7 @@ pub fn start(app: &AppHandle, id: CallId, retry: bool) -> Result<(), String> {
|
||||
let work_dir = upload_dir(app)?;
|
||||
let settings = state.settings();
|
||||
let opts = PipelineOptions {
|
||||
language: settings.language,
|
||||
language,
|
||||
deepscript_model: settings.deepscript_model,
|
||||
vocabulary: settings.vocabulary,
|
||||
};
|
||||
|
||||
+45
-3
@@ -122,16 +122,21 @@ pub struct CallBrief {
|
||||
pub started_at: DateTime<Local>,
|
||||
pub ended_at: Option<DateTime<Local>>,
|
||||
pub duration_secs: i64,
|
||||
/// What the language picker starts on
|
||||
/// ([`call_view::preselect_language`]).
|
||||
pub language: String,
|
||||
}
|
||||
|
||||
impl CallBrief {
|
||||
fn of(call: &Call) -> Self {
|
||||
/// `last_used_language` is the settings' `language`.
|
||||
fn of(call: &Call, last_used_language: &str) -> Self {
|
||||
Self {
|
||||
id: call.id,
|
||||
app: call.app.clone(),
|
||||
started_at: call.started_at,
|
||||
ended_at: call.ended_at,
|
||||
duration_secs: call_view::duration_secs(call),
|
||||
language: call_view::preselect_language(call, last_used_language),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,6 +444,15 @@ impl AppState {
|
||||
lock(&self.upload_confirmed_unsaved).insert(id);
|
||||
}
|
||||
|
||||
/// Remembers `language` as the last used one, preselected for the next
|
||||
/// call. Not saving it is only logged: the transcription it was chosen
|
||||
/// for goes ahead regardless.
|
||||
pub fn remember_language(&self, language: &str) {
|
||||
if let Err(e) = self.update_settings(|s| s.language = language.to_string()) {
|
||||
log::error!("could not remember the call language: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Changes and saves settings the app manages itself; saves only if
|
||||
/// something changed.
|
||||
fn update_settings(&self, change: impl FnOnce(&mut Settings)) -> Result<(), String> {
|
||||
@@ -646,7 +660,7 @@ impl AppState {
|
||||
match self.store.get_call(id) {
|
||||
Ok(Some(call)) => {
|
||||
return Some(PendingPrompt {
|
||||
brief: CallBrief::of(&call),
|
||||
brief: CallBrief::of(&call, &self.settings().language),
|
||||
more_waiting: queue.len() - 1,
|
||||
})
|
||||
}
|
||||
@@ -676,7 +690,10 @@ impl AppState {
|
||||
}
|
||||
|
||||
pub fn call_brief(&self, id: CallId) -> Result<CallBrief, String> {
|
||||
Ok(CallBrief::of(&self.find_call(id)?))
|
||||
Ok(CallBrief::of(
|
||||
&self.find_call(id)?,
|
||||
&self.settings().language,
|
||||
))
|
||||
}
|
||||
|
||||
/// All calls for the main window's list, newest first.
|
||||
@@ -1198,11 +1215,36 @@ mod tests {
|
||||
started_at: at(10, 14, 0),
|
||||
ended_at: Some(at(10, 46, 30)),
|
||||
duration_secs: 32 * 60 + 30,
|
||||
language: "de".into(),
|
||||
}
|
||||
);
|
||||
assert!(f.state.call_brief(id + 1).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_brief_preselects_the_calls_language_else_the_last_used() {
|
||||
let f = fixture();
|
||||
let (id, _, _) = finished_call(&f, "a");
|
||||
f.state.remember_language("fr");
|
||||
assert_eq!(f.state.call_brief(id).unwrap().language, "fr");
|
||||
|
||||
f.state.store.set_language(id, "it").unwrap();
|
||||
assert_eq!(f.state.call_brief(id).unwrap().language, "it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_last_used_language_is_remembered_across_restarts() {
|
||||
let f = fixture();
|
||||
|
||||
f.state.remember_language("es");
|
||||
|
||||
assert_eq!(f.state.settings().language, "es");
|
||||
assert_eq!(
|
||||
Settings::load(&f.dir.path().join("settings.json")).language,
|
||||
"es"
|
||||
);
|
||||
}
|
||||
|
||||
fn queued(f: &Fixture) -> Option<(CallId, usize)> {
|
||||
f.state
|
||||
.pending_prompt()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Gesprächsrekorder",
|
||||
"version": "0.3.1",
|
||||
"version": "0.4.0",
|
||||
"identifier": "eu.euvino.callrecorder",
|
||||
"build": {
|
||||
"frontendDist": "../ui/dist",
|
||||
@@ -36,7 +36,7 @@
|
||||
"label": "prompt",
|
||||
"title": "Gespräch beendet",
|
||||
"url": "index.html#/prompt",
|
||||
"width": 340,
|
||||
"width": 400,
|
||||
"height": 180,
|
||||
"alwaysOnTop": true,
|
||||
"visible": false,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ui",
|
||||
"private": true,
|
||||
"version": "0.3.1",
|
||||
"version": "0.4.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { CALL_LANGUAGES } from './api'
|
||||
|
||||
// The language a call is transcribed in, picked next to "Transkribieren"
|
||||
// and "Erneut versuchen".
|
||||
let { value = $bindable(), disabled = false }: { value: string; disabled?: boolean } = $props()
|
||||
</script>
|
||||
|
||||
<select bind:value {disabled} title="Sprache des Gesprächs" aria-label="Sprache des Gesprächs">
|
||||
{#each CALL_LANGUAGES as language (language.code)}
|
||||
<option value={language.code}>{language.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
+18
-2
@@ -5,10 +5,20 @@ import { listen, type UnlistenFn } from '@tauri-apps/api/event'
|
||||
|
||||
export type CallId = number
|
||||
|
||||
/** The languages a call can be transcribed in (the backend's `CALL_LANGUAGES`). */
|
||||
export const CALL_LANGUAGES = [
|
||||
{ code: 'de', label: 'Deutsch' },
|
||||
{ code: 'en', label: 'Englisch' },
|
||||
{ code: 'es', label: 'Spanisch' },
|
||||
{ code: 'fr', label: 'Französisch' },
|
||||
{ code: 'it', label: 'Italienisch' },
|
||||
] as const
|
||||
|
||||
export interface Settings {
|
||||
allowlist: string[]
|
||||
mic_device: string | null
|
||||
output_device: string | null
|
||||
/** Language of the transcription started last; set by the app, not the settings page. */
|
||||
language: string
|
||||
deepscript_model: string
|
||||
/** Custom words/names submitted with every transcription. */
|
||||
@@ -72,6 +82,8 @@ export interface CallBrief {
|
||||
started_at: string
|
||||
ended_at: string | null
|
||||
duration_secs: number
|
||||
/** What the language picker starts on: the call's own language, else the last used. */
|
||||
language: string
|
||||
}
|
||||
|
||||
/** The call the end-of-call prompt shows, and how many wait behind it. */
|
||||
@@ -144,6 +156,8 @@ export interface CallDetail {
|
||||
audio_available: boolean
|
||||
/** Retention deleted the call's audio (not just: the files are missing). */
|
||||
audio_deleted: boolean
|
||||
/** What the language picker starts on: the call's own language, else the last used. */
|
||||
language: string
|
||||
}
|
||||
|
||||
/** A call's two tracks mixed into one file, ready to play from
|
||||
@@ -197,8 +211,10 @@ export const stopRecording = () => invoke<void>('stop_recording')
|
||||
export const discardCurrentRecording = () => invoke<void>('discard_current_recording')
|
||||
export const getPendingPrompt = () => invoke<PendingPrompt | null>('get_pending_prompt')
|
||||
export const getCallBrief = (id: CallId) => invoke<CallBrief>('get_call_brief', { id })
|
||||
export const transcribeCall = (id: CallId) => invoke<void>('transcribe_call', { id })
|
||||
export const retryCall = (id: CallId) => invoke<void>('retry_call', { id })
|
||||
export const transcribeCall = (id: CallId, language: string) =>
|
||||
invoke<void>('transcribe_call', { id, language })
|
||||
export const retryCall = (id: CallId, language: string) =>
|
||||
invoke<void>('retry_call', { id, language })
|
||||
export const discardCall = (id: CallId) => invoke<void>('discard_call', { id })
|
||||
/** Mixes the call's tracks (or reuses the cached mix); refused while the
|
||||
* call is recorded or processed and once its audio is gone. */
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
} from '../lib/api'
|
||||
import CallList from '../lib/CallList.svelte'
|
||||
import { formatDateTime, formatDetailTime, formatMinutes } from '../lib/format'
|
||||
import LanguageSelect from '../lib/LanguageSelect.svelte'
|
||||
import Player from '../lib/Player.svelte'
|
||||
import { segmentAt } from '../lib/playback'
|
||||
import StatusPill from '../lib/StatusPill.svelte'
|
||||
@@ -45,6 +46,8 @@
|
||||
let selectedId = $state<CallId | null>(null)
|
||||
let detail = $state<CallDetail | null>(null)
|
||||
let detailError = $state('')
|
||||
/** The language picked for the shown call's transcription. */
|
||||
let language = $state('de')
|
||||
let actionError = $state('')
|
||||
let busy = $state(false)
|
||||
|
||||
@@ -109,6 +112,12 @@
|
||||
try {
|
||||
const next = await getCall(id)
|
||||
if (request === detailRequest && id === selectedId) {
|
||||
// A refresh of the same call keeps what the user picked, unless the
|
||||
// backend's suggestion changed (e.g. it was transcribed from the
|
||||
// prompt in another language and failed).
|
||||
if (next.call.id !== detail?.call.id || next.language !== detail?.language) {
|
||||
language = next.language
|
||||
}
|
||||
detail = next
|
||||
detailError = ''
|
||||
}
|
||||
@@ -219,8 +228,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
const transcribe = () => run(transcribeCall)
|
||||
const retry = () => run(retryCall)
|
||||
const transcribe = () => run((id) => transcribeCall(id, language))
|
||||
const retry = () => run((id) => retryCall(id, language))
|
||||
const discard = () =>
|
||||
run(discardCall, () => {
|
||||
clearSelection()
|
||||
@@ -466,9 +475,11 @@
|
||||
{/if}
|
||||
<span class="actions">
|
||||
{#if call.status === 'awaiting_decision'}
|
||||
<LanguageSelect bind:value={language} disabled={busy} />
|
||||
<button class="btn primary" disabled={busy} onclick={transcribe}>Transkribieren</button>
|
||||
<button class="btn danger" disabled={busy} onclick={discard}>Verwerfen</button>
|
||||
{:else if call.status === 'failed'}
|
||||
<LanguageSelect bind:value={language} disabled={busy} />
|
||||
<button class="btn primary" disabled={busy} onclick={retry}>Erneut versuchen</button>
|
||||
<button class="btn danger" disabled={busy} onclick={discard}>Verwerfen</button>
|
||||
{:else if call.status === 'done'}
|
||||
|
||||
@@ -11,13 +11,21 @@
|
||||
type PendingPrompt,
|
||||
} from '../lib/api'
|
||||
import { formatMinutes, formatTimeRange } from '../lib/format'
|
||||
import LanguageSelect from '../lib/LanguageSelect.svelte'
|
||||
|
||||
let brief = $state<PendingPrompt | null>(null)
|
||||
let busy = $state(false)
|
||||
let error = $state('')
|
||||
let language = $state('de')
|
||||
|
||||
function show(next: PendingPrompt | null) {
|
||||
if (next?.id !== brief?.id) error = ''
|
||||
// A refresh of the same call keeps what the user picked, unless the
|
||||
// backend's suggestion changed (e.g. a transcription started from the
|
||||
// main window in another language).
|
||||
if (next && (next.id !== brief?.id || next.language !== brief?.language)) {
|
||||
language = next.language
|
||||
}
|
||||
brief = next
|
||||
}
|
||||
|
||||
@@ -54,6 +62,8 @@
|
||||
busy = false
|
||||
}
|
||||
}
|
||||
|
||||
const transcribe = () => run((id) => transcribeCall(id, language))
|
||||
</script>
|
||||
|
||||
<main class="prompt">
|
||||
@@ -64,7 +74,8 @@
|
||||
<div class="muted">Weitere Gespräche warten: {brief.more_waiting}</div>
|
||||
{/if}
|
||||
<div class="actions">
|
||||
<button class="btn primary" disabled={busy} onclick={() => run(transcribeCall)}>
|
||||
<LanguageSelect bind:value={language} disabled={busy} />
|
||||
<button class="btn primary" disabled={busy} onclick={transcribe}>
|
||||
Transkribieren
|
||||
</button>
|
||||
<button class="btn danger" disabled={busy} onclick={() => run(discardCall)}>Verwerfen</button>
|
||||
|
||||
@@ -482,11 +482,6 @@
|
||||
<section class="card">
|
||||
<h2>Allgemein</h2>
|
||||
<div class="grid">
|
||||
<label for="language">Sprache der Gespräche</label>
|
||||
<select id="language" bind:value={settings.language}>
|
||||
<option value="de">Deutsch</option>
|
||||
<option value="en">Englisch</option>
|
||||
</select>
|
||||
<label for="retention">Aufbewahrung der Audiodateien</label>
|
||||
<span><input id="retention" type="number" min="1" max="3650" bind:value={settings.retention_days} /> Tage</span>
|
||||
<span></span>
|
||||
|
||||
Reference in New Issue
Block a user