feat #14740: transcription model choice, vocabulary and short-word corrections

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-10 13:10:50 +01:00
co-authored by Claude Sonnet 5
parent c57eb9511d
commit 8d757fd639
11 changed files with 472 additions and 12 deletions
+61
View File
@@ -201,6 +201,15 @@ impl Transcriber for DeepScript {
value: "1".to_string(),
});
}
if !opts.vocabulary.is_empty() {
parts.push(Part::Text {
name: "vocabulary".to_string(),
// The documented format: "JSON array of custom words, or
// comma-separated string."
value: serde_json::to_string(&opts.vocabulary)
.expect("Vec<String> always serializes"),
});
}
let req = HttpRequest {
method: Method::Post,
@@ -385,6 +394,7 @@ mod tests {
language: language.to_string(),
model: model.to_string(),
single_speaker,
vocabulary: Vec::new(),
}
}
@@ -439,6 +449,57 @@ mod tests {
transport.assert_done();
}
#[tokio::test]
async fn submit_sends_vocabulary_as_a_json_array_string() {
let transport = Arc::new(FakeTransport::new());
transport.expect(
Method::Post,
&format!("{BASE}/transcriptions"),
202,
r#"{"data":{"id":"job-voc","status":"queued","model":"premium","originalFileName":"mic.flac","createdOn":"2026-01-01T00:00:00Z"}}"#,
);
let ds = deep_script(&transport);
let mut vocab_opts = opts("premium", "de", true);
vocab_opts.vocabulary = vec!["Tschüss".to_string(), "Euvino".to_string()];
ds.submit(Path::new("mic.flac"), &vocab_opts).await.unwrap();
let requests = transport.requests();
let HttpBody::Multipart(parts) = &requests[0].body else {
panic!("expected multipart body");
};
assert!(parts.contains(&Part::Text {
name: "vocabulary".to_string(),
value: r#"["Tschüss","Euvino"]"#.to_string(),
}));
transport.assert_done();
}
#[tokio::test]
async fn submit_omits_vocabulary_when_empty() {
let transport = Arc::new(FakeTransport::new());
transport.expect(
Method::Post,
&format!("{BASE}/transcriptions"),
202,
r#"{"data":{"id":"job-novoc","status":"queued","model":"premium","originalFileName":"mic.flac","createdOn":"2026-01-01T00:00:00Z"}}"#,
);
let ds = deep_script(&transport);
ds.submit(Path::new("mic.flac"), &opts("premium", "de", true))
.await
.unwrap();
let requests = transport.requests();
let HttpBody::Multipart(parts) = &requests[0].body else {
panic!("expected multipart body");
};
assert!(!parts
.iter()
.any(|p| matches!(p, Part::Text { name, .. } if name == "vocabulary")));
transport.assert_done();
}
#[tokio::test]
async fn submit_without_hint_for_output_track() {
let transport = Arc::new(FakeTransport::new());