Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

---

AutoSubs s'occupe de ce qui arrive **une fois la vidéo prête** : récupérer les timings mot-à-mot depuis Whisper/Speaches ou un fichier de sous-titres existant, corriger le texte, réparer les timings, appliquer un style, prévisualiser le bon format et laisser FFmpeg/libass incruster le résultat. Pour les traitements récurrents, un Workflow surveille un dossier et exécute le même pipeline automatiquement.
AutoSubs s'occupe de ce qui arrive **une fois la vidéo prête** : récupérer les timings acoustiques mot-à-mot depuis Speaches/Parakeet Ultra (par défaut), ou Whisper ou un fichier de sous-titres existant, corriger le texte, réparer les timings, appliquer un style, prévisualiser le bon format et laisser FFmpeg/libass incruster le résultat. Pour les traitements récurrents, un Workflow surveille un dossier et exécute le même pipeline automatiquement.

Le navigateur n'est pas le moteur métier. Rust possède la normalisation des timings, le découpage des lignes, la persistance, le rendu et l'état des workflows. L'UI appelle cette API : un traitement manuel et un traitement automatique passent donc par les mêmes règles.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

---

AutoSubs is for the part that happens **after you have a video**: get word timings from Whisper/Speaches or import an existing subtitle file, clean up the text, repair bad timing, style it once, preview the right canvas, and let FFmpeg burn it with libass. For recurring work, a Workflow watches a folder and runs the same pipeline automatically.
AutoSubs is for the part that happens **after you have a video**: get acoustically aligned word timings from Speaches Parakeet Ultra (default), or from Whisper or import an existing subtitle file, clean up the text, repair bad timing, style it once, preview the right canvas, and let FFmpeg burn it with libass. For recurring work, a Workflow watches a folder and runs the same pipeline automatically.

It is deliberately not a browser-only subtitle toy. The Rust backend owns timing normalization, segmentation, persistence, rendering and workflow state. The web UI is a client of that API, so manual jobs and automated jobs go through the same rules.

Expand Down Expand Up @@ -315,7 +315,7 @@ In the Editor, scrub through the video preview and mark **Start here** and **End

### Cloud9 stand-up transcript/search utility

A local optional Python 3 utility under `tools/standup_corpus.py` inventories the stand-up media folder on Cloud9, chunks audio for the existing Speaches/WhisperX alignment services, saves same-stem Markdown/SRT/word-timestamp JSON sidecars, and updates an SQLite FTS5 search index with absolute video timestamps. The corpus utility is optional and Cloud9-specific; it is **not** enabled for general Docker or AppImage installs. See `tools/STANDUP_CORPUS_CLOUD9.md` for service setup, status, query examples, and original-media safeguards.
A local optional Python 3 utility under `tools/standup_corpus.py` inventories the stand-up media folder on Cloud9, chunks audio for the existing Speaches Parakeet Ultra native word-timing API (without a separate aligner), saves same-stem Markdown/SRT/word-timestamp JSON sidecars, and updates an SQLite FTS5 search index with absolute video timestamps. The corpus utility is optional and Cloud9-specific; it is **not** enabled for general Docker or AppImage installs. See `tools/STANDUP_CORPUS_CLOUD9.md` for service setup, status, query examples, and original-media safeguards.

## Development

Expand Down
5 changes: 3 additions & 2 deletions frontend/src/lib/speaches-discovery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const MODEL_PREFS = [
'handy-computer/parakeet-ultra-gguf',
'deepdml/faster-whisper-large-v3-turbo-ct2',
'Systran/faster-whisper-large-v3',
];
Expand Down Expand Up @@ -43,14 +44,14 @@ export async function probeSpeaches(value, fetcher = fetch) {
if (!health || !Array.isArray(models?.data)) throw new Error('Invalid Cloud9-Speaches API response');
const ids = /** @type {{id?:string}[]} */ (models.data).map(x => x?.id).filter(x => typeof x === 'string');
const model = MODEL_PREFS.find(x => ids.includes(x));
if (!model) throw new Error('No supported Whisper Turbo model is installed');
if (!model) throw new Error('No supported word-timestamp ASR model is installed');
return {
origin,
transcriptionUrl: origin + '/v1/audio/transcriptions',
alignmentUrl: '',
model,
alignmentModel: '',
backend: 'whisper-native-words',
backend: model.includes('parakeet-ultra') ? 'parakeet-ultra-ctc-words' : 'whisper-native-words',
backendVerified: false,
};
}
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/lib/views/SettingsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
const next: SettingsView = {
...previous, localTranscriptionEnabled: true, localFallbackEnabled: false,
localTranscriptionUrl: found.transcriptionUrl,
localTranscriptionModel: found.model
localTranscriptionModel: found.model,
// Strict native CTC requires an explicit language; preserve existing selection.
language: found.model.includes('parakeet-ultra')
? (previous.language.trim() || 'fr')
: previous.language
};
// Preserve all secret keys and the existing primary/OmniRoute provider.
await api.saveSettings(next);
Expand Down Expand Up @@ -68,7 +72,7 @@
<div class="field"><label for="speaches-connect-base">Cloud9-Speaches server URL</label><input id="speaches-connect-base" class="input" bind:value={speachesAddress} placeholder="http://127.0.0.1:8005"/></div>
<div class="row wrap"><button class="btn primary" disabled={!loaded||speachesBusy} on:click={connectSpeaches}>{speachesBusy ? 'Checking…' : 'Connect Cloud9-Speaches'}</button>
{#if speachesPrevious}<button class="btn" disabled={speachesBusy} on:click={undoSpeaches}>Undo connection</button>{/if}</div>
<p class="help">Uses Whisper Turbo native word timing, without any separate aligner; missing timestamps are rejected. For a Docker deployment on another machine, enter its reachable private-LAN HTTPS/HTTP address.</p>
<p class="help">Prefers Parakeet Ultra with native acoustic word alignment in Speaches. Missing or inferred word timestamps are rejected. Explicit language is required (French by default). For a Docker deployment on another machine, enter its reachable private-LAN HTTPS/HTTP address.</p>
</div>
</section>
<section class="card"><div class="card-header"><strong>{$dictionary.primaryProvider}</strong></div><div class="card-body stack">
Expand Down
12 changes: 11 additions & 1 deletion frontend/tests/speaches-discovery.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ test('discovers native word-timestamp Whisper Turbo without forced aligner', asy
assert.equal(calls.length,2);
});

test('prioritizes Parakeet Ultra when both supported ASR models are present', async () => {
const fake = async (url) => ({ok:true,json:async()=>url.endsWith('/v1/models')
? {data:[{id:'deepdml/faster-whisper-large-v3-turbo-ct2'},{id:'handy-computer/parakeet-ultra-gguf'}]}
: {message:'OK'}});
const result = await probeSpeaches('http://127.0.0.1:8005',fake);
assert.equal(result.model,'handy-computer/parakeet-ultra-gguf');
assert.equal(result.backend,'parakeet-ultra-ctc-words');
assert.equal(result.backendVerified,false);
});

test('rejects missing Whisper model before changing settings', async () => {
const fake = async (url) => ({ok:true,json:async()=>url.endsWith('/v1/models')?{data:[]}:{message:'OK'}});
await assert.rejects(() => probeSpeaches('http://127.0.0.1:8005',fake),/Whisper Turbo/);
await assert.rejects(() => probeSpeaches('http://127.0.0.1:8005',fake),/word-timestamp ASR model/);
});

test('one-click connection performs same-origin authenticated-app-server probe only', async () => {
Expand Down
11 changes: 9 additions & 2 deletions src/api/speaches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
};

const MODEL_PREFS: &[&str] = &[
"handy-computer/parakeet-ultra-gguf",
"deepdml/faster-whisper-large-v3-turbo-ct2",
"Systran/faster-whisper-large-v3",
];
Expand Down Expand Up @@ -175,14 +176,20 @@ pub async fn probe(Json(request): Json<ProbeRequest>) -> AppResult<Json<ProbeRes
ids.iter()
.any(|item| item.get("id").and_then(Value::as_str) == Some(**preference))
})
.ok_or_else(|| AppError::BadRequest("No supported Whisper Turbo model available".into()))?;
.ok_or_else(|| {
AppError::BadRequest("No supported word-timestamp ASR model available".into())
})?;
Ok(Json(ProbeResponse {
transcription_url: format!("{origin}/v1/audio/transcriptions"),
alignment_url: String::new(),
origin,
model: (*model).to_owned(),
alignment_model: "",
backend: "whisper-native-words".to_owned(),
backend: if model.contains("parakeet-ultra") {
"parakeet-ultra-ctc-words".to_owned()
} else {
"whisper-native-words".to_owned()
},
backend_verified: false, // Model metadata alone does not prove word timing.
}))
}
Expand Down
2 changes: 1 addition & 1 deletion src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl Default for Settings {
local_transcription_api_key: std::env::var("AUTOSUBS_LOCAL_TRANSCRIPTION_API_KEY")
.unwrap_or_default(),
local_transcription_model: std::env::var("AUTOSUBS_LOCAL_TRANSCRIPTION_MODEL")
.unwrap_or_else(|_| "large-v3".into()),
.unwrap_or_else(|_| "handy-computer/parakeet-ultra-gguf".into()),
alignment_enabled: std::env::var("AUTOSUBS_ALIGNMENT_ENABLED")
.map(|v| matches!(v.to_ascii_lowercase().as_str(), "1" | "true" | "yes" | "on"))
.unwrap_or(false),
Expand Down
90 changes: 89 additions & 1 deletion src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,32 @@ fn validated_native_word_timeline(
.ok_or_else(|| {
anyhow!(
"the selected ASR engine has no native word timestamps; \
use a word-timestamp-capable model (Faster-Whisper)"
use a word-timestamp-capable model (Parakeet Ultra / Faster-Whisper)"
)
})?;
if !media_duration.is_finite() || media_duration <= 0.0 {
bail!("invalid source audio duration");
}
// The provider must timestamp every recognized lexical character.
// Whitespace-only token-count differences are allowed (punctuation or
// clitics); silently dropping a real word is not.
if let Some(text) = &transcription.text {
let letters = |value: &str| {
value
.chars()
.filter(|c| c.is_alphanumeric())
.flat_map(char::to_lowercase)
.collect::<String>()
};
let timed_text: String = native
.iter()
.filter_map(|word| word.word.as_deref())
.collect::<Vec<_>>()
.join(" ");
if letters(text) != letters(&timed_text) {
bail!("ASR native word timestamps omit or alter recognized text");
}
}
let mut grouped = Vec::<RawWord>::with_capacity(native.len());
let mut pending = Vec::<String>::new();
let mut pending_at = None::<f64>;
Expand Down Expand Up @@ -2224,6 +2244,64 @@ mod tests {
assert_eq!(timeline.words[6].word, "vexés");
}

#[test]
fn reject_native_word_timestamps_when_recognized_word_is_missing() {
let input = TranscriptionResponse {
text: Some("bonjour les amis".into()),
words: Some(vec![
RawWord {
word: Some("bonjour".into()),
start: Some(0.1),
end: Some(0.45),
},
RawWord {
word: Some("amis".into()),
start: Some(0.55),
end: Some(0.85),
},
]),
segments: None,
};
assert!(
validated_native_word_timeline(&input, 1.0)
.unwrap_err()
.to_string()
.contains("omit or alter")
);
}

#[test]
fn accept_native_word_timings_when_whitespace_tokens_differ_but_lexemes_match() {
let input = TranscriptionResponse {
text: Some("aujourd'hui est magnifique".into()),
words: Some(vec![
RawWord {
word: Some("aujourd'".into()),
start: Some(0.1),
end: Some(0.35),
},
RawWord {
word: Some("hui".into()),
start: Some(0.35),
end: Some(0.55),
},
RawWord {
word: Some("est".into()),
start: Some(0.55),
end: Some(0.7),
},
RawWord {
word: Some("magnifique".into()),
start: Some(0.7),
end: Some(1.2),
},
]),
segments: None,
};
let line = validated_native_word_timeline(&input, 1.3).unwrap();
assert_eq!(line.timing_quality, TimingQuality::Exact);
}

#[test]
fn coalesce_zero_span_whisper_clitics_without_inventing_times_or_words() {
let src = TranscriptionResponse {
Expand Down Expand Up @@ -2292,6 +2370,16 @@ mod tests {
end: Some(1.55 + idx as f64 * 0.10),
});
}
// The text-only reference must include every timed lexical word.
// The previous fixture appended 120 word spans without transcript text.
let filler = (0..120)
.map(|idx| format!("suite{idx}"))
.collect::<Vec<_>>()
.join(" ");
realistic.text = Some(format!(
"{} {filler}",
src.text.as_deref().unwrap_or_default()
));
let timeline = validated_native_word_timeline(&realistic, 14.0).unwrap();
assert_eq!(timeline.timing_quality, TimingQuality::Inferred);
assert_eq!(timeline.words[0].word, "C'est");
Expand Down
38 changes: 24 additions & 14 deletions src/media/transcribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ pub(crate) fn models_endpoint(url: &str) -> String {
}

// Capability-gated requests, not a hardwired option for every model.
fn supports_whisper_word_timestamps(model: &str) -> bool {
fn supports_native_word_timestamps(model: &str) -> bool {
let model = model.trim().to_ascii_lowercase();
model.contains("whisper") || model.ends_with("-ct2") || model.contains("/ct2")
model.contains("whisper")
|| model.ends_with("-ct2")
|| model.contains("/ct2")
|| model.ends_with("/parakeet-ultra-gguf")
|| model == "parakeet-ultra-gguf"
}

async fn request_endpoint(
Expand All @@ -88,22 +92,22 @@ async fn request_endpoint(
.file_name("audio.wav")
.mime_str("audio/wav")
.map_err(TranscriptionError::Http)?;
// Whisper/CT2 implement the OpenAI verbose_json word timestamp extension.
// Other OpenAI-compatible ASR engines (notably Qwen3-ASR GGUF) may reject
// timestamp_granularities with 422/503 even when plain JSON is supported.
// Whisper/CT2 and Speaches Parakeet Ultra (strict native CTC) support the
// OpenAI verbose_json word timestamp extension. Other ASR engines, such as
// Qwen3-ASR and Parakeet TDT, may reject timestamp_granularities.
// Parse any native words they return, but NEVER synthesize or silently
// assert native timings if the response is only text. The AutoSubs job
// gate can invoke its optional one-shot aligner or fail closed.
let wants_whisper_words = supports_whisper_word_timestamps(model);
let wants_native_words = supports_native_word_timestamps(model);
let mut form = multipart::Form::new().part("file", part).text(
"response_format",
if wants_whisper_words {
if wants_native_words {
"verbose_json"
} else {
"json"
},
);
if wants_whisper_words {
if wants_native_words {
form = form.text("timestamp_granularities[]", "word");
}
if !model.trim().is_empty() {
Expand Down Expand Up @@ -270,18 +274,24 @@ mod endpoint_regression_tests {

#[test]
fn request_word_timestamp_capability_is_model_aware() {
assert!(supports_whisper_word_timestamps(
assert!(supports_native_word_timestamps(
"deepdml/faster-whisper-large-v3-turbo-ct2"
));
assert!(supports_whisper_word_timestamps("whisper-large-v3-turbo"));
assert!(supports_whisper_word_timestamps("whisper-1"));
assert!(!supports_whisper_word_timestamps(
assert!(supports_native_word_timestamps("whisper-large-v3-turbo"));
assert!(supports_native_word_timestamps("whisper-1"));
assert!(supports_native_word_timestamps(
"handy-computer/parakeet-ultra-gguf"
));
assert!(supports_native_word_timestamps(
"other-provider/parakeet-ultra-gguf"
));
assert!(!supports_native_word_timestamps(
"handy-computer/Qwen3-ASR-1.7B-gguf"
));
assert!(!supports_whisper_word_timestamps(
assert!(!supports_native_word_timestamps(
"nvidia/parakeet-tdt-0.6b-v3"
));
assert!(!supports_whisper_word_timestamps("gpt-transcribe"));
assert!(!supports_native_word_timestamps("gpt-transcribe"));
}

#[tokio::test]
Expand Down
Loading
Loading