From 7170a7d96cc9844cdefcb7fa63221f66bc1dcbb7 Mon Sep 17 00:00:00 2001 From: Emrah Date: Sun, 18 Oct 2026 22:40:13 +0300 Subject: [PATCH 1/3] Add Turkish speech recognition with seda-v0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turkish now has a streaming model in the registry: atasoglu/seda-v0.1, a Zipformer2 transducer trained on Common Voice and the ISSAI Turkish Speech Corpus (Apache-2.0, ~73 MB, int8 encoder and joiner). The four file hashes were pinned from bytes downloaded and hashed locally, not copied from the Hub listing. The model writes lowercase spoken-form Turkish, and Unicode's default lowercase gets Turkish wrong both ways: `I` becomes `i` where the model writes `ı`, and `İ` becomes `i` plus a combining dot no transcript contains. A capitalised script line ("IŞIK", "İSTANBUL") could therefore never match. The matcher now compares through `fold_case`, which folds I, İ, i and ı to one `i` without needing to know the script's language, still per grapheme so offsets cannot shift. The real-model smoke test takes TEXTREAM_TEST_MODEL_ID so it can load any registry entry, not only the default English one. Run against seda with Windows' Turkish TTS voice, the transcript came back word for word and the matcher reached the end of the script. Co-Authored-By: Claude Opus 5.5 --- README.md | 17 +++++++------ crates/prompt-core/src/matcher.rs | 39 +++++++++++++++++----------- crates/prompt-core/src/text.rs | 42 +++++++++++++++++++++++++++++++ src-tauri/src/model.rs | 19 ++++++++++++++ src-tauri/src/speech.rs | 15 +++++------ 5 files changed, 104 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 8a4162d..f827732 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ --- > **v1.0.** All three guidance modes work end to end. Speech recognition -> covers several languages but not Turkish yet — see +> covers several languages, Turkish included — see > [Languages](#languages).

@@ -171,13 +171,15 @@ exactly when somebody has published a streaming model for it: | English (small) — fastest, the default | 42 MB | | English, German, French | 71 MB each | | Spanish | 156 MB | +| Turkish | 73 MB | | Chinese (Mandarin) | 77 MB | | Arabic, Indonesian, Japanese, Russian, Thai, Vietnamese (one model) | 339 MB | -**Turkish is not available yet.** A model exists — Kroko publishes a Turkish -community streaming model — but only in their own packaging, and nobody has -converted it to the ONNX layout sherpa-onnx loads. That conversion is the whole -job; the app already handles everything after it. +Turkish uses [seda-v0.1](https://huggingface.co/atasoglu/seda-v0.1), a +streaming Zipformer2 transducer trained on Common Voice and the ISSAI Turkish +Speech Corpus (Apache-2.0). Its transcripts are lowercase, so the matcher folds +`I`, `İ`, `i` and `ı` together — Unicode's default lowercase gets Turkish wrong, +and a capitalised script line would otherwise never match what was said. Adding a language is a few lines in [`model.rs`](src-tauri/src/model.rs) and a published model to point at. @@ -266,7 +268,7 @@ cargo test --workspace - [x] Classic and Voice-Activated modes end to end - [x] On-device streaming speech recognition — Word Tracking works - [x] A model registry covering several languages -- [ ] Turkish, once a streaming model is converted for it +- [x] Turkish - [x] Settings that persist across launches - [x] Font, size, colour and opacity - [x] Pause, hold, and mute from the transport dock @@ -304,7 +306,8 @@ approach to word tracking are all his design. Speech recognition uses [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx) by the k2-fsa team, with streaming models published by -[csukuangfj](https://huggingface.co/csukuangfj). +[csukuangfj](https://huggingface.co/csukuangfj) and, for Turkish, +[atasoglu](https://huggingface.co/atasoglu). The dyslexia-friendly typeface is [OpenDyslexic](https://opendyslexic.org) by Abbie Gonzalez, bundled under the diff --git a/crates/prompt-core/src/matcher.rs b/crates/prompt-core/src/matcher.rs index 6c7cbde..b7d277a 100644 --- a/crates/prompt-core/src/matcher.rs +++ b/crates/prompt-core/src/matcher.rs @@ -21,7 +21,7 @@ use crate::alignment::{ DEFAULT_AGREEMENT_TOLERANCE, }; use crate::script::PromptScript; -use crate::text::{graphemes, is_readable, split_into_words}; +use crate::text::{fold_case, graphemes, is_readable, split_into_words}; /// How far the matcher may look ahead on either side when it hits a mismatch. const MAX_SKIP: usize = 5; @@ -54,15 +54,10 @@ impl PromptMatcher { source.annotation_ranges(), offset.min(source.character_count()), ); - // Lowercasing per grapheme rather than over the whole string keeps a - // 1:1 index mapping. A whole-string lowercase can change the grapheme - // count (Turkish `İ` expands to two scalars) and silently shift every - // offset the matcher returns. - let lowered = source - .graphemes() - .iter() - .map(|g| g.to_lowercase()) - .collect(); + // Folding per grapheme rather than over the whole string keeps a 1:1 + // index mapping, so no case change can shift the offsets the matcher + // returns. + let lowered = source.graphemes().iter().map(|g| fold_case(g)).collect(); Self { source, @@ -174,7 +169,7 @@ impl PromptMatcher { /// transcript reaches. fn character_level_match(&self, spoken: &str) -> usize { let source = &self.lowered[self.match_start_offset..]; - let spoken: Vec = graphemes(&spoken.to_lowercase()) + let spoken: Vec = graphemes(&fold_case(spoken)) .into_iter() .filter(|g| is_readable(g) || g.chars().all(char::is_whitespace)) .collect(); @@ -257,7 +252,7 @@ impl PromptMatcher { .source .slice(self.match_start_offset..self.source.character_count()); let source_words: Vec<&str> = remaining.split(' ').filter(|w| !w.is_empty()).collect(); - let spoken_words = split_into_words(&spoken.to_lowercase()); + let spoken_words = split_into_words(&fold_case(spoken)); let mut source_index = 0usize; let mut spoken_index = 0usize; @@ -265,9 +260,9 @@ impl PromptMatcher { let mut inside_annotation = false; let alnum = |word: &str| -> String { - word.chars() + fold_case(word) + .chars() .filter(|c| c.is_alphanumeric()) - .flat_map(char::to_lowercase) .collect() }; let width = |word: &str| graphemes(word).len(); @@ -594,6 +589,22 @@ mod tests { assert!(m.recognized_character_count() > 0); } + #[test] + fn turkish_capitals_match_a_lowercase_transcript() { + // The Turkish model writes lowercase spoken form, so `I` must meet + // `ı` and `İ` must meet `i`. + let mut m = matcher("IŞIK SÖNDÜ İSTANBUL'DA"); + m.match_transcript("ışık söndü istanbulda"); + assert_eq!(m.recognized_character_count(), m.source().character_count()); + } + + #[test] + fn a_dotted_capital_does_not_shift_offsets() { + let mut m = matcher("İzmir güzel bir şehir"); + m.match_transcript("izmir güzel"); + assert_eq!(m.source().slice(0..m.recognized_character_count()).trim_end(), "İzmir güzel"); + } + #[test] fn word_progress_follows_the_highlight() { let mut m = matcher("alpha beta gamma"); diff --git a/crates/prompt-core/src/text.rs b/crates/prompt-core/src/text.rs index 3f55437..37555fd 100644 --- a/crates/prompt-core/src/text.rs +++ b/crates/prompt-core/src/text.rs @@ -118,6 +118,27 @@ pub fn infer_direction(text: &str) -> TextDirection { TextDirection::LeftToRight } +/// Lowercases `text` for comparison, folding the four Turkish i's together. +/// +/// Unicode's default lowercase is wrong for Turkish in both directions: `I` +/// becomes `i` where a Turkish recogniser writes `ı`, and `İ` becomes `i` plus +/// a combining dot that no transcript ever contains. So a script line such as +/// "IŞIK" or "İSTANBUL" would never match what was said. Folding `I`, `İ`, `i` +/// and `ı` to one `i` fixes Turkish without needing to know the language, and +/// costs the matcher nothing elsewhere — it is fuzzy about single letters +/// anyway, and no other language contrasts dotted with dotless i. +pub fn fold_case(text: &str) -> String { + let mut folded = String::with_capacity(text.len()); + for c in text.chars().flat_map(char::to_lowercase) { + match c { + 'ı' => folded.push('i'), + '\u{0307}' if folded.ends_with('i') => {} + other => folded.push(other), + } + } + folded +} + /// Splits `text` into owned grapheme clusters — the unit every offset in this /// crate is measured in. pub fn graphemes(text: &str) -> Vec { @@ -188,6 +209,27 @@ mod tests { assert_eq!(graphemes("a👍🏽b").len(), 3); } + #[test] + fn fold_case_unifies_the_turkish_i() { + assert_eq!(fold_case("IŞIK"), fold_case("ışık")); + assert_eq!(fold_case("İSTANBUL"), "istanbul"); + assert_eq!(fold_case("I\u{0307}stanbul"), "istanbul"); + assert_eq!(fold_case("Iğdır"), "iğdir"); + } + + #[test] + fn fold_case_keeps_one_grapheme_per_grapheme() { + for g in ["İ", "I", "ı", "Ş", "Ğ", "Ö", "Ü", "Ç"] { + assert_eq!(graphemes(&fold_case(g)).len(), 1, "{g}"); + } + } + + #[test] + fn fold_case_leaves_other_combining_dots_alone() { + // U+0307 after a letter other than i is real content and must survive. + assert_eq!(fold_case("a\u{0307}"), "a\u{0307}"); + } + #[test] fn readability_ignores_punctuation_and_emoji() { assert!(is_readable("word")); diff --git a/src-tauri/src/model.rs b/src-tauri/src/model.rs index 4312a4a..35a47ff 100644 --- a/src-tauri/src/model.rs +++ b/src-tauri/src/model.rs @@ -132,6 +132,25 @@ pub const MODELS: &[SpeechModel] = &[ }, download_bytes: 156_200_000, }, + SpeechModel { + id: "tr", + label: "Turkish", + language: "tr", + repo: "atasoglu/seda-v0.1", + files: ModelFiles { + encoder: "encoder.int8.onnx", + decoder: "decoder.onnx", + joiner: "joiner.int8.onnx", + tokens: "tokens.txt", + }, + hashes: ModelHashes { + encoder: "2596861911cec5ca1de31adc12a7fc983d05395434f92239f4e007eeae3a5dcc", + decoder: "dc28b7ae3f5e67c0daa2d51886dae2ac8287a25333f46a363f3684b3cd1220c9", + joiner: "b4d1cff7c410d14c85c143885954be09a6a4a076cd35d22aeba58655665582bb", + tokens: "f6e134fa357558d0c4ab56fbe380323c30e3d50a13fe402a68328d5a13c2236b", + }, + download_bytes: 72_800_000, + }, SpeechModel { id: "zh", label: "Chinese (Mandarin)", diff --git a/src-tauri/src/speech.rs b/src-tauri/src/speech.rs index 5641983..9fc95e0 100644 --- a/src-tauri/src/speech.rs +++ b/src-tauri/src/speech.rs @@ -297,8 +297,11 @@ mod tests { /// zeroed — get a field wrong and this is where it shows up, rather than in /// front of a presenter mid-take. /// + /// `TEXTREAM_TEST_MODEL_ID` picks which registry entry the directory holds, + /// defaulting to the default model. + /// /// ```text - /// TEXTREAM_TEST_MODEL_DIR=

cargo test -p textream -- --ignored + /// TEXTREAM_TEST_MODEL_DIR= TEXTREAM_TEST_MODEL_ID=tr cargo test -p textream -- --ignored /// ``` #[test] #[ignore = "needs a downloaded speech model"] @@ -306,13 +309,11 @@ mod tests { let Ok(directory) = std::env::var("TEXTREAM_TEST_MODEL_DIR") else { panic!("set TEXTREAM_TEST_MODEL_DIR to a directory holding a model"); }; - let files = ModelFiles { - encoder: "encoder-epoch-99-avg-1.int8.onnx", - decoder: "decoder-epoch-99-avg-1.int8.onnx", - joiner: "joiner-epoch-99-avg-1.int8.onnx", - tokens: "tokens.txt", + let model = match std::env::var("TEXTREAM_TEST_MODEL_ID") { + Ok(id) => crate::model::find(&id).unwrap_or_else(|| panic!("no model {id}")), + Err(_) => crate::model::default_model(), }; - let paths = ModelPaths::in_directory(Path::new(&directory), &files); + let paths = ModelPaths::in_directory(Path::new(&directory), &model.files); assert!(paths.all_present(), "model files missing in {directory}"); let mut recognizer = Recognizer::new(&paths).expect("recogniser should load"); From 4092f9131806c5254af1578a91c4bdd702495349 Mon Sep 17 00:00:00 2001 From: Emrah Date: Mon, 19 Oct 2026 23:17:50 +0300 Subject: [PATCH 2/3] Credit the Windows port and the Turkish support in the README Co-Authored-By: Claude Opus 5.5 --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f827732..92fb0ef 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,17 @@

The Windows port of Textream - by Fatih Kadir Akın + by Fatih Kadir Akın, + ported to Windows by CRTkafa, + with Turkish speech recognition added in this repository

+> 🇹🇷 **Türkçe:** Bu depo, [Fatih Kadir Akın](https://github.com/f)'ın macOS +> uygulaması [Textream](https://github.com/f/textream)'in +> [CRTkafa](https://x.com/CRTkafa) tarafından yapılan Windows portunu temel alır +> ve ona Türkçe konuşma tanıma desteği ekler. Sesli takip (Word Tracking) +> modunda Türkçe metinler artık kelime kelime izlenir. + --- > **v1.0.** All three guidance modes work end to end. Speech recognition @@ -302,7 +310,9 @@ icon with his blessing. The cue syntax, the three guidance modes, and the approach to word tracking are all his design. - Original macOS app: [github.com/f/textream](https://github.com/f/textream) -- Windows port: [CRT](https://git.crt.fyi/CRT) +- Windows port: [CRTkafa](https://x.com/CRTkafa) — + [git.crt.fyi/CRT/textream-windows](https://git.crt.fyi/CRT/textream-windows) +- Turkish speech recognition: [Emrah](https://github.com/veysiemrah) Speech recognition uses [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx) by the k2-fsa team, with streaming models published by From 7a64011810c7684e1761ebe37beaf9598239f412 Mon Sep 17 00:00:00 2001 From: CRT Date: Tue, 20 Oct 2026 03:59:01 +0700 Subject: [PATCH 3/3] Textream for Windows is now CRTkafa's and Emrah's: joint credits, 1.3.0 Emrah's Turkish speech recognition (seda-v0.1, the Turkish-aware case fold in the matcher) comes in as his own two commits. The README, the licence, the installer's copyright and the crate authors now name both, with links to his X profile and to the repository where his work was first published. The release scan takes its command from WAYBETTER_RELEASE_CHECK, since the public CLI no longer carries the scanner, and a dispatch-only workflow builds the same path-free installer on a Windows runner. --- .forgejo/workflows/release.yml | 33 +++++++++++++++++++++++++++++++++ Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- LICENSE | 2 +- README.md | 29 +++++++++++++++++++---------- package.json | 2 +- scripts/release.mjs | 4 +++- src-tauri/tauri.conf.json | 4 ++-- 8 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 .forgejo/workflows/release.yml diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..7daa371 --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,33 @@ +# The release installer, built path-free on a Windows runner. Run by hand only; the artifact is +# scanned with the private term list before it is attached to a release, never from here. +name: release +on: + workflow_dispatch: + inputs: + ref: + description: Commit or tag to build + required: true + default: master + +jobs: + windows: + runs-on: windows + timeout-minutes: 90 + defaults: + run: + # Git Bash by its path: the runner service's PATH need not hold it. + shell: '"C:\\Program Files\\Git\\bin\\bash.exe" --noprofile --norc -eo pipefail {0}' + steps: + - uses: https://code.forgejo.org/actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + - name: Build the installer, path-free + run: | + bun install + bunx waybetter@0.7.0 build-env --root "$PWD" -- bun run app:build + ls -l target/release/bundle/nsis/ + - uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: installer + if-no-files-found: error + path: target/release/bundle/nsis/*-setup.exe diff --git a/Cargo.lock b/Cargo.lock index 57bb169..9830d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3111,7 +3111,7 @@ dependencies = [ [[package]] name = "prompt-core" -version = "1.2.0" +version = "1.3.0" dependencies = [ "unicode-segmentation", ] @@ -4396,7 +4396,7 @@ dependencies = [ [[package]] name = "textream" -version = "1.2.0" +version = "1.3.0" dependencies = [ "cpal", "prompt-core", diff --git a/Cargo.toml b/Cargo.toml index 55cc2b7..5a49a81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,11 @@ members = ["crates/prompt-core", "src-tauri"] resolver = "2" [workspace.package] -version = "1.2.0" +version = "1.3.0" edition = "2021" rust-version = "1.80" license = "MIT" -authors = ["CRTkafa"] +authors = ["CRTkafa", "Emrah"] [workspace.dependencies] unicode-segmentation = "1.12" diff --git a/LICENSE b/LICENSE index 5c25383..6b3bf77 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 CRTkafa +Copyright (c) 2026 CRTkafa and Emrah Portions of the script-alignment, cue-handling and voice-activity logic are reimplementations of algorithms from Textream (https://github.com/f/textream), diff --git a/README.md b/README.md index 92fb0ef..b80aa15 100644 --- a/README.md +++ b/README.md @@ -15,19 +15,18 @@

The Windows port of Textream by Fatih Kadir Akın, - ported to Windows by CRTkafa, - with Turkish speech recognition added in this repository + made by CRTkafa and Emrah

-> 🇹🇷 **Türkçe:** Bu depo, [Fatih Kadir Akın](https://github.com/f)'ın macOS -> uygulaması [Textream](https://github.com/f/textream)'in -> [CRTkafa](https://x.com/CRTkafa) tarafından yapılan Windows portunu temel alır -> ve ona Türkçe konuşma tanıma desteği ekler. Sesli takip (Word Tracking) -> modunda Türkçe metinler artık kelime kelime izlenir. +> 🇹🇷 **Türkçe:** Textream for Windows, [Fatih Kadir Akın](https://github.com/f)'ın +> macOS uygulaması [Textream](https://github.com/f/textream)'in Windows sürümüdür. +> Windows portunu [CRTkafa](https://x.com/CRTkafa), Türkçe konuşma tanımayı +> [Emrah](https://x.com/vebaban_) yaptı; proje artık ikisinin. Sesli takip +> (Word Tracking) modunda Türkçe metinler kelime kelime izlenir. --- -> **v1.0.** All three guidance modes work end to end. Speech recognition +> **v1.3.** All three guidance modes work end to end. Speech recognition > covers several languages, Turkish included — see > [Languages](#languages). @@ -261,6 +260,12 @@ name listed in the file `WAYBETTER_FORBIDDEN_TERMS` points at, is still in it. Reviewed false positives live in `privacy-allowlist.txt`. It needs CMake and 7-Zip, and only an installer that passed is published. +`WAYBETTER_RELEASE_CHECK` names the scanner command when it is not the CLI's +own `privacy-scan`. Without a Windows machine, the `release` workflow in +[`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) builds the +same path-free installer on a Windows runner; it is scanned before it is +attached to a release. + Run the test suite: ```bash @@ -310,9 +315,13 @@ icon with his blessing. The cue syntax, the three guidance modes, and the approach to word tracking are all his design. - Original macOS app: [github.com/f/textream](https://github.com/f/textream) -- Windows port: [CRTkafa](https://x.com/CRTkafa) — +- Textream for Windows: [CRTkafa](https://x.com/CRTkafa) and + [Emrah](https://x.com/vebaban_), at [git.crt.fyi/CRT/textream-windows](https://git.crt.fyi/CRT/textream-windows) -- Turkish speech recognition: [Emrah](https://github.com/veysiemrah) + - Windows port: [CRTkafa](https://x.com/CRTkafa) + - Turkish speech recognition: [Emrah](https://x.com/vebaban_) — first + published in his repository, + [github.com/veysiemrah/textream-windows](https://github.com/veysiemrah/textream-windows) Speech recognition uses [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx) by the k2-fsa team, with streaming models published by diff --git a/package.json b/package.json index 74667fb..e6c3fc2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "textream-windows", "private": true, - "version": "1.2.0", + "version": "1.3.0", "type": "module", "scripts": { "dev": "vite", diff --git a/scripts/release.mjs b/scripts/release.mjs index e826bac..a3cf818 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -16,6 +16,8 @@ const root = dirname(dirname(fileURLToPath(import.meta.url))); const { version } = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')); const installer = join(root, 'target', 'release', 'bundle', 'nsis', `Textream_${version}_x64-setup.exe`); const waybetter = process.env.WAYBETTER_CLI ? ['node', process.env.WAYBETTER_CLI] : ['waybetter']; +// The scanner is no longer part of the public CLI: WAYBETTER_RELEASE_CHECK names the command that runs it. +const scanner = process.env.WAYBETTER_RELEASE_CHECK ? process.env.WAYBETTER_RELEASE_CHECK.split(' ') : [...waybetter, 'privacy-scan']; function run(step, [command, ...args]) { console.log(`\n== ${step}`); @@ -35,5 +37,5 @@ if (!existsSync(installer)) { console.error(`release: the build left no ${installer}`); process.exit(1); } -run('scan the installer', [...waybetter, 'privacy-scan', installer, '--allow', join(root, 'privacy-allowlist.txt')]); +run('scan the installer', [...scanner, installer, '--allow', join(root, 'privacy-allowlist.txt')]); console.log(`\nClean. Publishable: ${installer}`); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 20542c1..c993e50 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Textream", - "version": "1.2.0", + "version": "1.3.0", "identifier": "dev.crtkafa.textream", "build": { "beforeDevCommand": "bun run dev", @@ -61,7 +61,7 @@ "runtime/sherpa-onnx-c-api.dll": "sherpa-onnx-c-api.dll", "runtime/sherpa-onnx-cxx-api.dll": "sherpa-onnx-cxx-api.dll" }, - "copyright": "Copyright (c) 2026 CRTkafa", + "copyright": "Copyright (c) 2026 CRTkafa and Emrah", "shortDescription": "Teleprompter for Windows", "longDescription": "A free Windows teleprompter with real-time word tracking, classic auto-scroll and voice-activated scrolling. Everything runs on-device.", "windows": {