Skip to content

Commit abf465e

Browse files
release 0.2.0: reliability, cancellation, exports and ux overhaul
1 parent e24e403 commit abf465e

14 files changed

Lines changed: 1155 additions & 222 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ jobs:
3838
sudo apt-get install -y clang libclang-dev cmake pkg-config
3939
4040
- run: cargo fmt --all -- --check
41-
- run: cargo clippy --locked --all-targets -- -D warnings
42-
- run: cargo test --locked --all-targets
41+
- run: cargo clippy --locked --all-targets --all-features -- -D warnings
42+
- run: cargo test --locked --all-targets --all-features
4343

4444
release:
4545
name: release (${{ matrix.target }})

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# the crates.io name "scribe" was taken years ago. the command is still
33
# `scribe`; only the package name had to get creative.
44
name = "scribe-tui"
5-
version = "0.1.0"
5+
version = "0.2.0"
66
edition = "2024"
77
rust-version = "1.88"
88
description = "local, offline, cpu-only speech to text in the terminal"

‎readme.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ the managed copy if you have none.
4444
Models live in `~/.cache/scribe/models`. Press `m` in the TUI to pick one and it
4545
downloads itself from Hugging Face. Start with `small-q5_1`. Downloads are
4646
checked against the upstream SHA-256 before they are accepted; a bad file gets
47-
deleted and retried.
47+
deleted and retried. Catalog names (`small-q5_1`, `large-v3-turbo-q5_0`), their
48+
`ggml-*.bin` filenames, and explicit filesystem paths all work with `--model`.
49+
A name that is not in the catalog and is not a path is rejected with a clear
50+
error instead of being guessed. Cached files are size-checked on use and
51+
verified before activation in the picker.
4852

4953
Settings made in the TUI persist in `~/.config/scribe/config` (or
5054
`$XDG_CONFIG_HOME/scribe/config`). Command-line options win over saved values.
@@ -174,9 +178,12 @@ Custom ggml files work through `--model <path>` but do not show up in the picker
174178
`txt`, `srt`, `vtt`, `md`, `json`. Files go next to the source, or into `--out`.
175179
Existing files are not overwritten; move them yourself.
176180

177-
Word timings come from whisper's token data. `srt` and `vtt` get per-word cues,
178-
`json` gets a `words` array per segment, and markdown turns each word into a
179-
clickable timestamp link when the source is a YouTube URL.
181+
Word timings come from whisper's token data. In `srt` and `vtt`, segments with
182+
word timings produce one cue per word (no overlapping segment cue); segments
183+
without word timings produce a single segment cue. Cues are sorted, clamped so
184+
they never overlap, and sanitized to one line. `json` gets a `words` array per
185+
segment, and markdown turns each word into a clickable timestamp link when the
186+
source is a YouTube URL.
180187

181188
## performance notes
182189

‎src/app.rs‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,17 @@ impl App {
500500
self.follow = true;
501501
self.progress = 0.0;
502502
self.progress_smooth = 0.0;
503+
self.envelope.fill(0.0);
504+
self.envelope_smooth.fill(0.0);
503505
self.done_seconds = 0.0;
504506
self.started = None;
505507
self.finished_at = None;
506508
self.paused_at = None;
507509
self.pending_resume = false;
508510
self.paused_total = 0.0;
511+
self.query.clear();
512+
self.matches.clear();
513+
self.match_idx = 0;
509514
self.status = Status::Fetching;
510515
self.stage_started = Instant::now();
511516
self.overlay = Overlay::None;
@@ -972,6 +977,42 @@ mod tests {
972977
assert_eq!(app.progress, 0.5);
973978
}
974979

980+
#[test]
981+
fn repeated_jobs_do_not_retain_stale_state() {
982+
let mut app = App::new(&Args::default());
983+
app.status = Status::Transcribing;
984+
app.on_segment(Segment::new(0, 100, "old".into()));
985+
app.done_seconds = 42.0;
986+
app.progress = 0.8;
987+
app.query = "old".into();
988+
app.recompute_search();
989+
app.finished_at = Some(Instant::now());
990+
991+
app.start();
992+
assert!(app.segments.is_empty());
993+
assert_eq!(app.done_seconds, 0.0);
994+
assert_eq!(app.progress, 0.0);
995+
assert!(app.finished_at.is_none());
996+
assert!(app.follow);
997+
assert!(app.query.is_empty());
998+
assert!(app.matches.is_empty());
999+
}
1000+
1001+
#[test]
1002+
fn cancel_after_pause_settles_clock() {
1003+
let mut app = App::new(&Args::default());
1004+
app.status = Status::Transcribing;
1005+
app.started = Some(Instant::now() - std::time::Duration::from_secs(5));
1006+
app.pause();
1007+
assert!(app.pending_resume);
1008+
std::thread::sleep(std::time::Duration::from_millis(10));
1009+
app.on_cancelled();
1010+
assert!(!app.pending_resume);
1011+
assert!(app.paused_at.is_none());
1012+
assert_eq!(app.status, Status::Cancelled);
1013+
assert!(app.elapsed_s() <= 5.5, "paused time should be excluded");
1014+
}
1015+
9751016
#[test]
9761017
fn search_and_jump() {
9771018
let mut app = App::new(&Args::default());

‎src/cli.rs‎

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,13 @@ pub const HELP_SECTIONS: &[HelpSection] = &[
121121
desc: "force the completion list open",
122122
},
123123
HelpLine {
124-
key: "esc / space / p",
124+
key: "esc",
125125
desc: "pause active job; press again to stop",
126126
},
127+
HelpLine {
128+
key: "space / p",
129+
desc: "pause or resume the active job",
130+
},
127131
HelpLine {
128132
key: "c",
129133
desc: "stop active job, keeping saved segments",
@@ -297,6 +301,7 @@ pub fn parse(argv: &[String]) -> Result<Args, String> {
297301
"--help" | "-h" => out.help = true,
298302
"--version" | "-V" => out.version = true,
299303
"--no-tui" => out.no_tui = true,
304+
"--translate" => out.translate = Some(true),
300305
"--model" | "-m" => {
301306
let value = need_value(argv, &mut i, arg)?;
302307
if value.starts_with('-') {
@@ -402,8 +407,51 @@ mod tests {
402407
assert!(a(&["--threads"]).is_err());
403408
assert!(a(&["--threads", "x"]).is_err());
404409
assert!(a(&["--threads", "0"]).is_err());
410+
assert!(a(&["--threads", "257"]).is_err());
405411
assert!(a(&["--format", "nope"]).is_err());
406412
assert!(a(&["--unknown"]).is_err());
407413
assert!(a(&["a", "b"]).is_err());
414+
assert!(a(&["--model"]).is_err());
415+
assert!(a(&["--lang"]).is_err());
416+
assert!(a(&["--out"]).is_err());
417+
assert!(a(&["--theme"]).is_err());
418+
}
419+
420+
#[test]
421+
fn all_options_parse() {
422+
let args = a(&[
423+
"audio.wav",
424+
"--model",
425+
"small-q5_1",
426+
"--threads",
427+
"8",
428+
"--lang",
429+
"de",
430+
"--translate",
431+
"--out",
432+
"/tmp/out",
433+
"--format",
434+
"vtt",
435+
"--theme",
436+
"nord",
437+
"--no-tui",
438+
])
439+
.unwrap();
440+
assert_eq!(args.input.as_deref(), Some("audio.wav"));
441+
assert_eq!(args.model.unwrap().to_str(), Some("small-q5_1"));
442+
assert_eq!(args.threads, Some(8));
443+
assert_eq!(args.lang.as_deref(), Some("de"));
444+
assert!(args.translate.unwrap());
445+
assert_eq!(args.out.unwrap().to_str(), Some("/tmp/out"));
446+
assert_eq!(args.format, Format::Vtt);
447+
assert!(args.format_explicit);
448+
assert_eq!(args.theme.as_deref(), Some("nord"));
449+
assert!(args.no_tui);
450+
}
451+
452+
#[test]
453+
fn separator_accepts_dashed_input() {
454+
let args = a(&["--", "-weird-name.wav"]).unwrap();
455+
assert_eq!(args.input.as_deref(), Some("-weird-name.wav"));
408456
}
409457
}

0 commit comments

Comments
 (0)