Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

add chinese script selector + simplify internals (#2186)

CJ Pais0bb0428ea6e9
diff --git a/src-tauri/src/actions.rs b/src-tauri/src/actions.rs
index 31895ef8..cce7cfe4 100644
--- a/src-tauri/src/actions.rs
+++ b/src-tauri/src/actions.rs
@@ -14,7 +14,6 @@ use crate::utils::{
self, show_processing_overlay, show_recording_overlay, show_transcribing_overlay,
};
use crate::TranscriptionCoordinator;
-use ferrous_opencc::{config::BuiltinConfig, OpenCC};
use log::{debug, error, warn};
use once_cell::sync::Lazy;
use std::collections::HashMap;
@@ -345,81 +344,12 @@ async fn post_process_transcription(settings: &AppSettings, transcription: &str)
}
}
-async fn maybe_convert_chinese_variant(
- effective_language: &str,
- transcription: &str,
-) -> Option<String> {
- // Gate on the language the model actually transcribed in (the effective
- // language), not the persisted intent. A leftover zh-Hans/zh-Hant intent
- // from a previously selected model must not run OpenCC S2T/T2S over output a
- // non-Chinese model produced — that would silently rewrite any shared CJK
- // characters (e.g. Japanese kanji) in the result.
- let is_simplified = effective_language == "zh-Hans";
- let is_traditional = effective_language == "zh-Hant";
-
- if !is_simplified && !is_traditional {
- debug!("effective language is not Simplified or Traditional Chinese; skipping conversion");
- return None;
- }
-
- debug!(
- "Starting Chinese variant conversion using OpenCC for language: {}",
- effective_language
- );
-
- // Use OpenCC to convert based on selected language
- let config = if is_simplified {
- // Convert Traditional Chinese to Simplified Chinese
- BuiltinConfig::Tw2sp
- } else {
- // Convert Simplified Chinese to Traditional Chinese
- BuiltinConfig::S2tw
- };
-
- match OpenCC::from_config(config) {
- Ok(converter) => {
- let converted = converter.convert(transcription);
- debug!(
- "OpenCC translation completed. Input length: {}, Output length: {}",
- transcription.len(),
- converted.len()
- );
- Some(converted)
- }
- Err(e) => {
- error!("Failed to initialize OpenCC converter: {}. Falling back to original transcription.", e);
- None
- }
- }
-}
-
pub(crate) struct ProcessedTranscription {
pub final_text: String,
pub post_processed_text: Option<String>,
pub post_process_prompt: Option<String>,
}
-/// Resolve the persisted language *intent* into the language the currently-loaded
-/// model will actually use — the same capability-aware coercion the transcription
-/// paths apply (see [`crate::managers::model::effective_language`]). Post-processing
-/// resolves it independently so it agrees with the language the transcription ran
-/// in, without threading a value through the pipeline.
-fn resolve_effective_language(app: &AppHandle, settings: &AppSettings) -> String {
- let tm = app.state::<Arc<TranscriptionManager>>();
- let model_manager = app.state::<Arc<ModelManager>>();
- let active_model = tm
- .get_current_model()
- .unwrap_or_else(|| settings.selected_model.clone());
- match model_manager.get_model_info(&active_model) {
- Some(info) => crate::managers::model::effective_language(
- &settings.selected_language,
- &info.supported_languages,
- info.supports_language_detection,
- ),
- None => settings.selected_language.clone(),
- }
-}
-
pub(crate) async fn process_transcription_output(
app: &AppHandle,
transcription: &str,
@@ -430,16 +360,6 @@ pub(crate) async fn process_transcription_output(
let mut post_processed_text: Option<String> = None;
let mut post_process_prompt: Option<String> = None;
- // Resolve the language the transcription actually ran in (the persisted
- // intent coerced against the loaded model's capabilities) so OpenCC keys off
- // the effective language rather than a possibly-stale intent.
- let effective_language = resolve_effective_language(app, &settings);
- if let Some(converted_text) =
- maybe_convert_chinese_variant(&effective_language, transcription).await
- {
- final_text = converted_text;
- }
-
if post_process {
if let Some(processed_text) = post_process_transcription(&settings, &final_text).await {
post_processed_text = Some(processed_text.clone());
@@ -455,8 +375,6 @@ pub(crate) async fn process_transcription_output(
}
}
}
- } else if final_text != transcription {
- post_processed_text = Some(final_text.clone());
}
ProcessedTranscription {
diff --git a/src-tauri/src/audio_toolkit/lang_id.rs b/src-tauri/src/audio_toolkit/lang_id.rs
index 82834bdb..7775b7da 100644
--- a/src-tauri/src/audio_toolkit/lang_id.rs
+++ b/src-tauri/src/audio_toolkit/lang_id.rs
@@ -1,10 +1,10 @@
//! Confidence-gated text-based language identification.
//!
-//! Last-resort evidence for filler-word removal when neither the user's
-//! language selection nor the transcription model identifies the output
-//! language. Detection is constrained to the languages the active model can
-//! produce and fails closed: any doubt returns `None`, which callers treat as
-//! an unknown output language.
+//! Last-resort evidence for filler-word removal and Chinese script conversion
+//! when neither the user's language selection nor the transcription model
+//! identifies the output language. Detection is constrained to the languages
+//! the active model can produce and fails closed: any doubt returns `None`,
+//! which callers treat as an unknown output language.
use whatlang::{Detector, Lang};
diff --git a/src-tauri/src/audio_toolkit/text.rs b/src-tauri/src/audio_toolkit/text.rs
index 40686f03..5bbe4943 100644
--- a/src-tauri/src/audio_toolkit/text.rs
+++ b/src-tauri/src/audio_toolkit/text.rs
@@ -285,7 +285,7 @@ pub enum OutputLanguageEvidence {
}
impl OutputLanguageEvidence {
- fn language(&self) -> Option<&str> {
+ pub(crate) fn language(&self) -> Option<&str> {
match self {
Self::UserSelected(language)
| Self::ModelConstrained(language)
diff --git a/src-tauri/src/chinese_script.rs b/src-tauri/src/chinese_script.rs
new file mode 100644
index 00000000..36326fe7
--- /dev/null
+++ b/src-tauri/src/chinese_script.rs
@@ -0,0 +1,131 @@
+//! Simplified / Traditional script handling for Chinese transcription output.
+//!
+//! Recognition language (Mandarin vs Cantonese) and output script are separate
+//! choices: the language picks what the model listens for, and the
+//! [`ChineseScript`] setting picks how the resulting text is written. Conversion
+//! is keyed off the language the output is known to be in, so mixed-language
+//! users on auto-detect only get Chinese output rewritten.
+
+use crate::settings::ChineseScript;
+use ferrous_opencc::{config::BuiltinConfig, OpenCC};
+use log::error;
+use std::sync::OnceLock;
+
+/// The Chinese language a transcription was produced in. Picks the regional
+/// conversion tables: Taiwan for Mandarin, Hong Kong for Cantonese.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum ChineseVariety {
+ Mandarin,
+ Cantonese,
+}
+
+impl ChineseVariety {
+ /// Maps an output language code (`zh`, `zh-CN`, `yue`, …) to a Chinese
+ /// variety. Any other language returns `None` and is never converted.
+ pub fn from_language(language: &str) -> Option<Self> {
+ let base = language.split(&['-', '_'][..]).next()?.to_ascii_lowercase();
+ match base.as_str() {
+ "zh" => Some(Self::Mandarin),
+ "yue" => Some(Self::Cantonese),
+ _ => None,
+ }
+ }
+}
+
+/// The script a locale writes Chinese in, or `None` for non-Chinese locales.
+///
+/// `zh` defaults to Simplified unless tagged Hant or regioned to Taiwan, Hong
+/// Kong or Macau; Cantonese (`yue`) defaults to Traditional unless tagged Hans.
+pub fn chinese_script_for_locale(locale: &str) -> Option<ChineseScript> {
+ let normalized = locale.to_lowercase().replace('_', "-");
+ let subtags: Vec<_> = normalized.split('-').collect();
+ let is_hant = subtags.contains(&"hant");
+ let is_hans = subtags.contains(&"hans");
+ let is_traditional_region = ["tw", "hk", "mo"]
+ .iter()
+ .any(|region| subtags.contains(region));
+
+ let traditional = match subtags.first().copied() {
+ Some("zh") => is_hant || (!is_hans && is_traditional_region),
+ Some("yue") => !is_hans,
+ _ => return None,
+ };
+ Some(if traditional {
+ ChineseScript::Traditional
+ } else {
+ ChineseScript::Simplified
+ })
+}
+
+/// The OpenCC converter for a variety/script pair, built on first use and
+/// reused after. Building one parses its dictionaries, which is too slow to
+/// repeat on every live-preview update. A failed build is cached as `None`.
+fn converter(variety: ChineseVariety, script: ChineseScript) -> Option<&'static OpenCC> {
+ static MANDARIN_SIMPLIFIED: OnceLock<Option<OpenCC>> = OnceLock::new();
+ static MANDARIN_TRADITIONAL: OnceLock<Option<OpenCC>> = OnceLock::new();
+ static CANTONESE_SIMPLIFIED: OnceLock<Option<OpenCC>> = OnceLock::new();
+ static CANTONESE_TRADITIONAL: OnceLock<Option<OpenCC>> = OnceLock::new();
+
+ let (cell, config) = match (variety, script) {
+ (_, ChineseScript::AsTranscribed) => return None,
+ (ChineseVariety::Mandarin, ChineseScript::Simplified) => {
+ (&MANDARIN_SIMPLIFIED, BuiltinConfig::Tw2sp)
+ }
+ (ChineseVariety::Mandarin, ChineseScript::Traditional) => {
+ (&MANDARIN_TRADITIONAL, BuiltinConfig::S2tw)
+ }
+ (ChineseVariety::Cantonese, ChineseScript::Simplified) => {
+ (&CANTONESE_SIMPLIFIED, BuiltinConfig::Hk2s)
+ }
+ (ChineseVariety::Cantonese, ChineseScript::Traditional) => {
+ (&CANTONESE_TRADITIONAL, BuiltinConfig::S2hk)
+ }
+ };
+
+ cell.get_or_init(|| match OpenCC::from_config(config) {
+ Ok(converter) => Some(converter),
+ Err(e) => {
+ error!(
+ "Failed to initialize OpenCC converter: {}. Keeping the original script.",
+ e
+ );
+ None
+ }
+ })
+ .as_ref()
+}
+
+/// Rewrites `text` into `script`. Fails open: if OpenCC can't be initialized
+/// the text is returned unchanged.
+pub fn convert_chinese_script(
+ text: &str,
+ variety: ChineseVariety,
+ script: ChineseScript,
+) -> String {
+ match converter(variety, script) {
+ Some(converter) => converter.convert(text),
+ None => text.to_string(),
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn cantonese_uses_hong_kong_tables() {
+ // Hong Kong standard writes 裏 where Taiwan writes 裡.
+ assert_eq!(
+ convert_chinese_script(
+ "里面",
+ ChineseVariety::Cantonese,
+ ChineseScript::Traditional
+ ),
+ "裏面"
+ );
+ assert_eq!(
+ convert_chinese_script("裏面", ChineseVariety::Cantonese, ChineseScript::Simplified),
+ "里面"
+ );
+ }
+}
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 6a3baf45..898770bc 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -5,6 +5,7 @@ mod audio_feedback;
pub mod audio_toolkit;
mod autostart;
mod catalog;
+mod chinese_script;
pub mod cli;
mod clipboard;
mod commands;
@@ -695,6 +696,7 @@ pub fn run(cli_args: CliArgs) {
shortcut::change_vad_enabled_setting,
shortcut::change_vad_backend_setting,
shortcut::change_filler_word_removal_enabled_setting,
+ shortcut::change_chinese_script_setting,
shortcut::change_app_language_setting,
shortcut::change_update_checks_setting,
shortcut::change_show_whats_new_on_update_setting,
diff --git a/src-tauri/src/managers/model.rs b/src-tauri/src/managers/model.rs
index b7d8e4a2..2aeccf43 100644
--- a/src-tauri/src/managers/model.rs
+++ b/src-tauri/src/managers/model.rs
@@ -268,10 +268,7 @@ impl ModelDescriptor {
/// Matching is base-aware ([`base_language`]) and returns the model's own
/// *concrete* code, so a bare intent (`en`) resolves to the exact string the
/// engine's prompt table expects (`en-US`) for models that advertise full
-/// BCP-47 locales. Chinese *script* intents (`zh-Hans`/`zh-Hant`) are the sole
-/// exception: they pass through unchanged so the downstream Simplified /
-/// Traditional output conversion still fires (the engine path collapses them to
-/// a plain Chinese code separately).
+/// BCP-47 locales.
pub fn effective_language(
intent: &str,
supported_languages: &[String],
@@ -295,9 +292,6 @@ pub fn effective_language(
};
if let Some(code) = exact_base_match.or_else(equivalent_match) {
- if intent == "zh-Hans" || intent == "zh-Hant" {
- return intent.to_string();
- }
return code.clone();
}
}
@@ -2677,14 +2671,6 @@ mod tests {
use std::io::Write;
use tempfile::TempDir;
- #[test]
- fn test_effective_language_accepts_chinese_script_intent_for_zh_capability() {
- let languages = vec!["zh".to_string()];
-
- assert_eq!(effective_language("zh-Hans", &languages, false), "zh-Hans");
- assert_eq!(effective_language("zh-Hant", &languages, false), "zh-Hant");
- }
-
#[test]
fn test_effective_language_falls_back_to_canonical_chinese() {
let languages = vec!["zh-Hant".to_string()];
@@ -2714,16 +2700,6 @@ mod tests {
assert_eq!(effective_language("fr", &languages, true), "auto");
}
- #[test]
- fn test_effective_language_preserves_chinese_script_intent_for_locale_model() {
- // Script intents survive so Simplified/Traditional output conversion
- // still fires, even when the model advertises a regioned Chinese code.
- let languages = vec!["en-US".to_string(), "zh-CN".to_string()];
-
- assert_eq!(effective_language("zh-Hans", &languages, true), "zh-Hans");
- assert_eq!(effective_language("zh-Hant", &languages, true), "zh-Hant");
- }
-
#[test]
fn test_effective_language_preserves_intent_across_model_code_variants() {
assert_eq!(effective_language("no", &["nb".to_string()], true), "nb");
diff --git a/src-tauri/src/managers/transcription.rs b/src-tauri/src/managers/transcription.rs
index a8d0dddd..32de0c59 100644
--- a/src-tauri/src/managers/transcription.rs
+++ b/src-tauri/src/managers/transcription.rs
@@ -2,10 +2,11 @@ use crate::audio_toolkit::{
apply_custom_words, detect_output_language, normalize_transcription_output,
remove_filler_words, OutputLanguageEvidence,
};
+use crate::chinese_script::{convert_chinese_script, ChineseVariety};
use crate::managers::audio::AudioRecordingManager;
use crate::managers::model::{EngineType, ModelManager};
use crate::settings::{
- get_settings, AppSettings, ModelUnloadTimeout, OrtAcceleratorSetting,
+ get_settings, AppSettings, ChineseScript, ModelUnloadTimeout, OrtAcceleratorSetting,
TranscribeAcceleratorSetting,
};
use anyhow::Result;
@@ -953,6 +954,7 @@ impl TranscriptionManager {
// (and thus the engine) for its lifetime, so the feed/finalize loop
// lives in a labeled block — when it exits, the borrow is released and
// the engine can be moved into return_engine().
+ let mut preview_script = PreviewScript::new(settings.chinese_script, &output_language);
let mut finalize_reply: Option<mpsc::Sender<Option<FinalizedStreamText>>> = None;
let mut finalize_result: Option<Option<FinalizedStreamText>> = None;
let stream_started = 'stream: {
@@ -1002,7 +1004,12 @@ impl TranscriptionManager {
if update.committed_changed || update.tentative_changed {
let text = stream.text();
perf.record_emit();
- self.emit_stream_text(&text.committed, &text.tentative);
+ let (committed, tentative) = preview_script.convert(
+ &text.committed,
+ &text.tentative,
+ &languages,
+ );
+ self.emit_stream_text(&committed, &tentative);
}
perf.maybe_log();
}
@@ -1373,7 +1380,7 @@ impl TranscriptionManager {
anyhow::anyhow!("Moonshine streaming transcription failed: {}", e)
}),
LoadedEngine::SenseVoice(sense_voice_engine) => {
- let language = match normalize_cjk_language(&validated_language) {
+ let language = match validated_language.as_str() {
"zh" => Some("zh".to_string()),
"en" => Some("en".to_string()),
"ja" => Some("ja".to_string()),
@@ -1417,7 +1424,7 @@ impl TranscriptionManager {
let lang = if validated_language == "auto" {
None
} else {
- Some(normalize_cjk_language(&validated_language).to_string())
+ Some(validated_language.clone())
};
applied_language_hint = lang.clone();
let options = TranscribeOptions {
@@ -1649,13 +1656,6 @@ fn real_time_factor(audio_secs: f64, compute_secs: f64) -> f64 {
}
}
-fn normalize_cjk_language(language: &str) -> &str {
- match language {
- "zh-Hans" | "zh-Hant" => "zh",
- other => other,
- }
-}
-
/// Resolve the persisted language intent into the language a specific model can
/// use without writing the coerced value back to settings.
fn effective_language_for_model(
@@ -1746,7 +1746,7 @@ fn transcribe_cpp_run_plan(
) -> TranscribeCppRunPlan {
let requested_language = match effective_language {
"auto" => None,
- other => Some(normalize_cjk_language(other).to_string()),
+ other => Some(other.to_string()),
};
// Only pass a language the loaded model actually advertises (per
// capabilities().languages); otherwise auto-detect rather than failing with
@@ -1773,26 +1773,19 @@ fn post_process_transcription_text(
output_language: &OutputLanguageEvidence,
supported_languages: &[String],
) -> String {
+ let converts_script = settings.chinese_script != ChineseScript::AsTranscribed;
fail_open_text_transform(raw, |raw| {
- let corrected = if !settings.custom_words.is_empty() && !custom_words_already_prompted {
- apply_custom_words(
- &raw,
- &settings.custom_words,
- settings.word_correction_threshold,
- )
- } else {
- raw
- };
-
// Last-resort language evidence: confidence-gated detection from the
// transcribed text itself, constrained to the model's languages. Only
- // consulted when it can change the outcome (built-in gated fillers).
+ // consulted when it can change the outcome (built-in gated fillers or
+ // Chinese script conversion).
let output_language = match output_language {
OutputLanguageEvidence::Unknown
- if settings.filler_word_removal_enabled
- && settings.custom_filler_words.is_none() =>
+ if converts_script
+ || (settings.filler_word_removal_enabled
+ && settings.custom_filler_words.is_none()) =>
{
- match detect_output_language(&corrected, supported_languages) {
+ match detect_output_language(&raw, supported_languages) {
Some(language) => {
debug!("Text-based language detection resolved '{}'", language);
OutputLanguageEvidence::TextDetected(language)
@@ -1803,6 +1796,29 @@ fn post_process_transcription_text(
other => other.clone(),
};
+ // Convert the script before custom words so they match in the script
+ // the user writes in. Only output known to be Chinese is touched, so
+ // e.g. Japanese kanji are never rewritten.
+ let variety = output_language
+ .language()
+ .and_then(ChineseVariety::from_language);
+ let raw = match variety {
+ Some(variety) if converts_script => {
+ convert_chinese_script(&raw, variety, settings.chinese_script)
+ }
+ _ => raw,
+ };
+
+ let corrected = if !settings.custom_words.is_empty() && !custom_words_already_prompted {
+ apply_custom_words(
+ &raw,
+ &settings.custom_words,
+ settings.word_correction_threshold,
+ )
+ } else {
+ raw
+ };
+
let without_fillers = remove_filler_words(
&corrected,
&output_language,
@@ -1814,6 +1830,65 @@ fn post_process_transcription_text(
})
}
+/// Characters to wait for before detecting the preview's language. A lone
+/// Chinese character reads as Mandarin, but Japanese often opens with kanji
+/// before any kana; waiting a few characters keeps those from locking in.
+const PREVIEW_DETECTION_MIN_CHARS: usize = 6;
+
+/// Converts live-preview text into the configured Chinese script as it streams.
+///
+/// The preview is cosmetic: the final paste re-resolves the language and
+/// converts on its own, so this only has to look right while speaking.
+struct PreviewScript {
+ script: ChineseScript,
+ variety: Option<ChineseVariety>,
+ /// The language wasn't known when the stream started (auto-detect), so it
+ /// is detected from the streamed text until it turns out to be Chinese.
+ detect: bool,
+}
+
+impl PreviewScript {
+ fn new(script: ChineseScript, output_language: &OutputLanguageEvidence) -> Self {
+ let enabled = script != ChineseScript::AsTranscribed;
+ Self {
+ script,
+ variety: output_language
+ .language()
+ .and_then(ChineseVariety::from_language)
+ .filter(|_| enabled),
+ detect: enabled && *output_language == OutputLanguageEvidence::Unknown,
+ }
+ }
+
+ /// Converts the model's raw committed/tentative text. Always fed the raw
+ /// text, never a previous conversion, so it stays consistent with the
+ /// final conversion. Once Chinese is detected it sticks for the rest of
+ /// the stream so the preview doesn't flip back and forth.
+ fn convert(
+ &mut self,
+ committed: &str,
+ tentative: &str,
+ supported_languages: &[String],
+ ) -> (String, String) {
+ if self.variety.is_none() && self.detect {
+ let text = format!("{committed}{tentative}");
+ if text.chars().count() >= PREVIEW_DETECTION_MIN_CHARS {
+ self.variety = detect_output_language(&text, supported_languages)
+ .as_deref()
+ .and_then(ChineseVariety::from_language);
+ }
+ }
+
+ match self.variety {
+ Some(variety) => (
+ convert_chinese_script(committed, variety, self.script),
+ convert_chinese_script(tentative, variety, self.script),
+ ),
+ None => (committed.to_string(), tentative.to_string()),
+ }
+ }
+}
+
/// Optional text cleanup must never discard a successful model result. The
/// transform is pure and owns its input, so recovering the untouched text is
/// safe even if a bug in custom-word or filler filtering unwinds.
@@ -2229,6 +2304,47 @@ mod tests {
assert_eq!(result, raw);
}
+ #[test]
+ fn non_chinese_output_is_never_converted() {
+ let settings = AppSettings {
+ chinese_script: ChineseScript::Traditional,
+ ..Default::default()
+ };
+ for evidence in [
+ OutputLanguageEvidence::ModelDetected("ja".to_string()),
+ OutputLanguageEvidence::UserSelected("en".to_string()),
+ OutputLanguageEvidence::TranslatedToEnglish,
+ ] {
+ let result = post_process_transcription_text(
+ "学校に行きます".to_string(),
+ &settings,
+ false,
+ &evidence,
+ &languages(&["zh", "ja", "en"]),
+ );
+
+ assert_eq!(result, "学校に行きます", "{evidence:?}");
+ }
+ }
+
+ #[test]
+ fn auto_detected_chinese_text_is_converted() {
+ let settings = AppSettings {
+ chinese_script: ChineseScript::Simplified,
+ filler_word_removal_enabled: false,
+ ..Default::default()
+ };
+ let result = post_process_transcription_text(
+ "我們今天下午一起去學校圖書館看書,然後再去吃晚飯。".to_string(),
+ &settings,
+ false,
+ &OutputLanguageEvidence::Unknown,
+ &languages(&["zh", "en", "ja"]),
+ );
+
+ assert_eq!(result, "我们今天下午一起去学校图书馆看书,然后再去吃晚饭。");
+ }
+
#[test]
fn portuguese_transcription_does_not_use_english_ui_filler_words() {
let settings = AppSettings {
@@ -2456,15 +2572,6 @@ mod tests {
assert_eq!(evidence, OutputLanguageEvidence::TranslatedToEnglish);
}
- #[test]
- fn transcribe_cpp_run_plan_maps_chinese_variants() {
- let plan = transcribe_cpp_run_plan(false, "zh-Hant", &languages(&["zh"]), true);
-
- assert!(matches!(plan.task, Task::Transcribe));
- assert_eq!(plan.language.as_deref(), Some("zh"));
- assert_eq!(plan.target_language, None);
- }
-
#[test]
fn transcribe_cpp_run_plan_skips_english_translation() {
let plan = transcribe_cpp_run_plan(true, "en", &languages(&["en", "es"]), true);
diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs
index 182ae593..bd4ecbd9 100644
--- a/src-tauri/src/settings.rs
+++ b/src-tauri/src/settings.rs
@@ -179,6 +179,18 @@ pub enum ClipboardHandling {
CopyToClipboard,
}
+/// Script applied to Mandarin and Cantonese output. Other languages are never
+/// converted.
+#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Type, Default)]
+#[serde(rename_all = "snake_case")]
+pub enum ChineseScript {
+ /// Keep whatever script the model produced.
+ #[default]
+ AsTranscribed,
+ Simplified,
+ Traditional,
+}
+
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Type, Default)]
#[serde(rename_all = "snake_case")]
pub enum AutoSubmitKey {
@@ -490,6 +502,10 @@ pub struct AppSettings {
pub filler_word_removal_enabled: bool,
#[serde(default)]
pub custom_filler_words: Option<Vec<String>>,
+ /// Fresh installs default from the OS locale; existing stores are migrated
+ /// in `apply_settings_migrations`.
+ #[serde(default)]
+ pub chinese_script: ChineseScript,
#[serde(default)]
pub transcribe_accelerator: TranscribeAcceleratorSetting,
#[serde(default)]
@@ -585,6 +601,12 @@ fn default_filler_word_removal_enabled() -> bool {
true
}
+fn default_chinese_script() -> ChineseScript {
+ tauri_plugin_os::locale()
+ .and_then(|locale| crate::chinese_script::chinese_script_for_locale(&locale))
+ .unwrap_or_default()
+}
+
fn default_debug_mode() -> bool {
false
}
@@ -963,6 +985,7 @@ pub fn get_default_settings() -> AppSettings {
external_script_path: None,
filler_word_removal_enabled: default_filler_word_removal_enabled(),
custom_filler_words: None,
+ chinese_script: default_chinese_script(),
transcribe_accelerator: TranscribeAcceleratorSetting::default(),
ort_accelerator: OrtAcceleratorSetting::default(),
transcribe_gpu_device: default_transcribe_gpu_device(),
@@ -1136,6 +1159,22 @@ fn apply_settings_migrations(
}
}
+ // One-time Chinese script migration: the script used to be chosen through
+ // `zh-Hans`/`zh-Hant` language intents. Split those into the recognition
+ // language and the script setting; every other upgrading user keeps the
+ // unconverted output they had. Only fresh installs get the locale default.
+ if settings_value.get("chinese_script").is_none() {
+ settings.chinese_script = match settings.selected_language.as_str() {
+ "zh-Hans" => ChineseScript::Simplified,
+ "zh-Hant" => ChineseScript::Traditional,
+ _ => ChineseScript::AsTranscribed,
+ };
+ if settings.chinese_script != ChineseScript::AsTranscribed {
+ settings.selected_language = "zh".to_string();
+ }
+ updated = true;
+ }
+
let stored_schema_version = settings_value
.get("settings_schema_version")
.and_then(|v| v.as_u64())
@@ -1569,6 +1608,24 @@ mod tests {
assert_eq!(settings.overlay_position, OverlayPosition::Top);
}
+ #[test]
+ fn chinese_script_migration_only_carries_over_legacy_intents() {
+ for (intent, language, script) in [
+ ("zh-Hans", "zh", ChineseScript::Simplified),
+ ("zh-Hant", "zh", ChineseScript::Traditional),
+ ("auto", "auto", ChineseScript::AsTranscribed),
+ ] {
+ let mut settings = get_default_settings();
+ settings.selected_language = intent.to_string();
+ settings.chinese_script = ChineseScript::Traditional;
+ let raw = serde_json::json!({ "selected_language": intent });
+
+ assert!(apply_settings_migrations(&mut settings, &raw));
+ assert_eq!(settings.selected_language, language);
+ assert_eq!(settings.chinese_script, script);
+ }
+ }
+
#[test]
fn shortcut_activation_migration_maps_push_to_talk_true() {
let mut settings = get_default_settings();
@@ -1692,6 +1749,7 @@ mod tests {
"onboarding_completed": false,
"whats_new_last_seen_version": default_whats_new_last_seen_version(),
"overlay_style": "live",
+ "chinese_script": "as_transcribed",
"transcribe_accelerator": "gpu",
"transcribe_gpu_device": settings.transcribe_gpu_device
});
diff --git a/src-tauri/src/shortcut/mod.rs b/src-tauri/src/shortcut/mod.rs
index 6498cc0c..d02285de 100644
--- a/src-tauri/src/shortcut/mod.rs
+++ b/src-tauri/src/shortcut/mod.rs
@@ -21,9 +21,9 @@ use tauri::{AppHandle, Emitter, Manager};
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
use crate::settings::APPLE_INTELLIGENCE_DEFAULT_MODEL_ID;
use crate::settings::{
- self, get_settings, AutoSubmitKey, ClipboardHandling, KeyboardImplementation, LLMPrompt,
- OverlayPosition, OverlayStyle, PasteMethod, ShortcutActivation, ShortcutBinding, SoundTheme,
- Theme, TypingTool, VadBackend, APPLE_INTELLIGENCE_PROVIDER_ID,
+ self, get_settings, AutoSubmitKey, ChineseScript, ClipboardHandling, KeyboardImplementation,
+ LLMPrompt, OverlayPosition, OverlayStyle, PasteMethod, ShortcutActivation, ShortcutBinding,
+ SoundTheme, Theme, TypingTool, VadBackend, APPLE_INTELLIGENCE_PROVIDER_ID,
};
use crate::tray;
@@ -1322,6 +1322,15 @@ pub fn change_filler_word_removal_enabled_setting(
Ok(())
}
+#[tauri::command]
+#[specta::specta]
+pub fn change_chinese_script_setting(app: AppHandle, script: ChineseScript) -> Result<(), String> {
+ let mut settings = settings::get_settings(&app);
+ settings.chinese_script = script;
+ settings::write_settings(&app, settings);
+ Ok(())
+}
+
#[tauri::command]
#[specta::specta]
pub fn change_app_language_setting(app: AppHandle, language: String) -> Result<(), String> {
diff --git a/src-tauri/src/tray_i18n.rs b/src-tauri/src/tray_i18n.rs
index 2bdc84ca..310f991e 100644
--- a/src-tauri/src/tray_i18n.rs
+++ b/src-tauri/src/tray_i18n.rs
@@ -12,6 +12,8 @@
//! 2. Add translations to other locale files
//! 3. Update tray.rs to use the new field (e.g., strings.new_field)
+use crate::chinese_script::chinese_script_for_locale;
+use crate::settings::ChineseScript;
use once_cell::sync::Lazy;
use std::collections::HashMap;
@@ -27,23 +29,15 @@ pub fn get_tray_translations(locale: Option<String>) -> TrayStrings {
.unwrap_or("en")
.to_lowercase()
.replace('_', "-");
- let subtags: Vec<_> = normalized.split('-').collect();
- let language = subtags.first().copied().unwrap_or("en");
- let is_hant = subtags.contains(&"hant");
- let is_hans = subtags.contains(&"hans");
- let is_traditional_region = ["tw", "hk", "mo"]
- .iter()
- .any(|region| subtags.contains(region));
+ let language = normalized.split('-').next().unwrap_or("en");
let exact_match = TRANSLATIONS
.iter()
.find_map(|(code, strings)| code.eq_ignore_ascii_case(&normalized).then_some(strings));
- let fallback = match language {
- "zh" if is_hant || (!is_hans && is_traditional_region) => "zh-TW",
- // Cantonese uses Traditional Chinese unless explicitly tagged as Hans.
- "yue" if is_hans => "zh",
- "yue" => "zh-TW",
- _ => language,
+ let fallback = match chinese_script_for_locale(&normalized) {
+ Some(ChineseScript::Traditional) => "zh-TW",
+ Some(_) => "zh",
+ None => language,
};
exact_match
diff --git a/src/bindings.ts b/src/bindings.ts
index c6d39535..1d8fc9a3 100644
--- a/src/bindings.ts
+++ b/src/bindings.ts
@@ -383,6 +383,14 @@ async changeFillerWordRemovalEnabledSetting(enabled: boolean) : Promise<Result<n
else return { status: "error", error: e as any };
}
},
+async changeChineseScriptSetting(script: ChineseScript) : Promise<Result<null, string>> {
+ try {
+ return { status: "ok", data: await TAURI_INVOKE("change_chinese_script_setting", { script }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
async changeAppLanguageSetting(language: string) : Promise<Result<null, string>> {
try {
return { status: "ok", data: await TAURI_INVOKE("change_app_language_setting", { language }) };
@@ -988,7 +996,12 @@ selected_channel?: number | null; clamshell_microphone?: string | null; selected
* after the target app actually reads the transcript, instead of after a
* fixed delay. See `paste_tx`. macOS and Windows only.
*/
-reliable_paste?: boolean; typing_tool?: TypingTool; external_script_path?: string | null; filler_word_removal_enabled?: boolean; custom_filler_words?: string[] | null; transcribe_accelerator?: TranscribeAcceleratorSetting; ort_accelerator?: OrtAcceleratorSetting;
+reliable_paste?: boolean; typing_tool?: TypingTool; external_script_path?: string | null; filler_word_removal_enabled?: boolean; custom_filler_words?: string[] | null;
+/**
+ * Fresh installs default from the OS locale; existing stores are migrated
+ * in `apply_settings_migrations`.
+ */
+chinese_script?: ChineseScript; transcribe_accelerator?: TranscribeAcceleratorSetting; ort_accelerator?: OrtAcceleratorSetting;
/**
* Stable transcribe.cpp device selector. This is derived from the backend's
* `device_id` when available (or its name for backends such as Metal),
@@ -1009,6 +1022,15 @@ export type AudioDevice = { index: string; name: string; is_default: boolean }
export type AutoSubmitKey = "enter" | "ctrl_enter" | "cmd_enter"
export type AvailableAccelerators = { transcribe: string[]; ort: string[]; gpu_devices: GpuDeviceOption[] }
export type BindingResponse = { success: boolean; binding: ShortcutBinding | null; error: string | null }
+/**
+ * Script applied to Mandarin and Cantonese output. Other languages are never
+ * converted.
+ */
+export type ChineseScript =
+/**
+ * Keep whatever script the model produced.
+ */
+"as_transcribed" | "simplified" | "traditional"
export type ClipboardHandling = "dont_modify" | "copy_to_clipboard"
export type CustomSounds = { start: boolean; stop: boolean }
export type EngineType =
diff --git a/src/components/settings/ChineseScript.tsx b/src/components/settings/ChineseScript.tsx
new file mode 100644
index 00000000..a719ad78
--- /dev/null
+++ b/src/components/settings/ChineseScript.tsx
@@ -0,0 +1,54 @@
+import React from "react";
+import { useTranslation } from "react-i18next";
+import { Dropdown } from "../ui/Dropdown";
+import { SettingContainer } from "../ui/SettingContainer";
+import { useSettings } from "../../hooks/useSettings";
+import type { ChineseScript } from "@/bindings";
+
+interface ChineseScriptProps {
+ descriptionMode?: "inline" | "tooltip";
+ grouped?: boolean;
+}
+
+export const ChineseScriptSetting: React.FC<ChineseScriptProps> = React.memo(
+ ({ descriptionMode = "tooltip", grouped = false }) => {
+ const { t } = useTranslation();
+ const { getSetting, updateSetting, isUpdating } = useSettings();
+
+ const scriptOptions = [
+ {
+ value: "as_transcribed",
+ label: t("settings.advanced.chineseScript.options.asTranscribed"),
+ },
+ {
+ value: "simplified",
+ label: t("settings.advanced.chineseScript.options.simplified"),
+ },
+ {
+ value: "traditional",
+ label: t("settings.advanced.chineseScript.options.traditional"),
+ },
+ ];
+
+ const selectedScript = (getSetting("chinese_script") ||
+ "as_transcribed") as ChineseScript;
+
+ return (
+ <SettingContainer
+ title={t("settings.advanced.chineseScript.title")}
+ description={t("settings.advanced.chineseScript.description")}
+ descriptionMode={descriptionMode}
+ grouped={grouped}
+ >
+ <Dropdown
+ options={scriptOptions}
+ selectedValue={selectedScript}
+ onSelect={(value) =>
+ updateSetting("chinese_script", value as ChineseScript)
+ }
+ disabled={isUpdating("chinese_script")}
+ />
+ </SettingContainer>
+ );
+ },
+);
diff --git a/src/components/settings/LanguageSelector.tsx b/src/components/settings/LanguageSelector.tsx
index 6385df9f..dfa140dc 100644
--- a/src/components/settings/LanguageSelector.tsx
+++ b/src/components/settings/LanguageSelector.tsx
@@ -5,8 +5,8 @@ import { ResetButton } from "../ui/ResetButton";
import { useSettings } from "../../hooks/useSettings";
import {
getLanguageLabel,
+ LANGUAGES,
recognitionLanguage,
- SELECTABLE_LANGUAGES,
supportsLanguageCode,
} from "../../lib/constants/languages";
@@ -19,29 +19,22 @@ interface LanguageSelectorProps {
supportsLanguageDetection?: boolean;
}
-// Convert a concrete or aliased code to the picker entry that represents it.
-// Chinese script intents are already selectable and must remain intact; model
-// codes such as `en-US` and `nb` resolve to their canonical `en` / `no` entry.
-const pickerLanguage = (languageCode: string): string =>
- SELECTABLE_LANGUAGES.some((language) => language.value === languageCode)
- ? languageCode
- : recognitionLanguage(languageCode);
-
// Mirrors the matching logic of `effective_language` in
// src-tauri/src/managers/model.rs. The Rust function is authoritative for the
// *concrete* code the engine receives (e.g. `nb`); this resolves the canonical
// picker intent (e.g. `no`) so model switches preserve the user's language.
+// Model codes such as `en-US` and `nb` resolve to their `en` / `no` entry.
const effectiveLanguage = (
intent: string,
supported: string[],
supportsDetection: boolean,
): string => {
- if (supported.length === 0) return pickerLanguage(intent);
+ if (supported.length === 0) return recognitionLanguage(intent);
if (intent !== "auto" && supportsLanguageCode(supported, intent))
- return pickerLanguage(intent);
+ return recognitionLanguage(intent);
if (supportsDetection) return "auto";
if (supportsLanguageCode(supported, "en")) return "en";
- return pickerLanguage(supported[0]);
+ return recognitionLanguage(supported[0]);
};
export const LanguageSelector: React.FC<LanguageSelectorProps> = ({
@@ -91,8 +84,8 @@ export const LanguageSelector: React.FC<LanguageSelectorProps> = ({
const availableLanguages = useMemo(() => {
if (!supportedLanguages || supportedLanguages.length === 0)
- return SELECTABLE_LANGUAGES;
- return SELECTABLE_LANGUAGES.filter((lang) =>
+ return LANGUAGES;
+ return LANGUAGES.filter((lang) =>
lang.value === "auto"
? supportsLanguageDetection
: supportsLanguageCode(supportedLanguages, lang.value),
diff --git a/src/components/settings/advanced/AdvancedSettings.tsx b/src/components/settings/advanced/AdvancedSettings.tsx
index b9397d2c..69ec7148 100644
--- a/src/components/settings/advanced/AdvancedSettings.tsx
+++ b/src/components/settings/advanced/AdvancedSettings.tsx
@@ -22,6 +22,7 @@ import { VoiceActivityDetection } from "../VoiceActivityDetection";
import { AccelerationSelector } from "../AccelerationSelector";
import { LazyStreamClose } from "../LazyStreamClose";
import { FillerWordRemoval } from "../FillerWordRemoval";
+import { ChineseScriptSetting } from "../ChineseScript";
import { VadBackendSelector } from "../VadBackendSelector";
export const AdvancedSettings: React.FC = () => {
@@ -50,6 +51,7 @@ export const AdvancedSettings: React.FC = () => {
<SettingsGroup title={t("settings.advanced.groups.transcription")}>
<VoiceActivityDetection descriptionMode="tooltip" grouped={true} />
<FillerWordRemoval descriptionMode="tooltip" grouped={true} />
+ <ChineseScriptSetting descriptionMode="tooltip" grouped={true} />
<CustomWords descriptionMode="tooltip" grouped />
<AppendTrailingSpace descriptionMode="tooltip" grouped={true} />
</SettingsGroup>
diff --git a/src/components/settings/general/ModelSettingsCard.tsx b/src/components/settings/general/ModelSettingsCard.tsx
index 1e34aa50..03d8b1b1 100644
--- a/src/components/settings/general/ModelSettingsCard.tsx
+++ b/src/components/settings/general/ModelSettingsCard.tsx
@@ -5,10 +5,6 @@ import { LanguageSelector } from "../LanguageSelector";
import { TranslateToEnglish } from "../TranslateToEnglish";
import { useModelStore } from "../../../stores/modelStore";
import type { ModelInfo } from "@/bindings";
-import {
- CHINESE_LANGUAGE_CODE,
- getUniqueCapabilityLanguages,
-} from "@/lib/constants/languages";
export const ModelSettingsCard: React.FC = () => {
const { t } = useTranslation();
@@ -16,16 +12,8 @@ export const ModelSettingsCard: React.FC = () => {
const currentModelInfo = models.find((m: ModelInfo) => m.id === currentModel);
- const supportsLanguageSelection =
- currentModelInfo?.supports_language_selection ?? false;
- const capabilityLanguages = getUniqueCapabilityLanguages(
- currentModelInfo?.supported_languages ?? [],
- );
- const supportsChineseOnlyScriptSelection =
- capabilityLanguages.length === 1 &&
- capabilityLanguages[0] === CHINESE_LANGUAGE_CODE;
const showLanguageSelector =
- supportsLanguageSelection || supportsChineseOnlyScriptSelection;
+ currentModelInfo?.supports_language_selection ?? false;
const supportsTranslation = currentModelInfo?.supports_translation ?? false;
const hasAnySettings = showLanguageSelector || supportsTranslation;
diff --git a/src/components/settings/index.ts b/src/components/settings/index.ts
index 2384940f..12cccc1f 100644
--- a/src/components/settings/index.ts
+++ b/src/components/settings/index.ts
@@ -26,6 +26,7 @@ export { PostProcessingToggle } from "./PostProcessingToggle";
export { PostProcessingSettingsApi } from "./PostProcessingSettingsApi";
export { PostProcessingSettingsPrompts } from "./PostProcessingSettingsPrompts";
export { FillerWordRemoval } from "./FillerWordRemoval";
+export { ChineseScriptSetting } from "./ChineseScript";
export { AppDataDirectory } from "./AppDataDirectory";
export { ModelUnloadTimeoutSetting } from "./ModelUnloadTimeout";
export { StartHidden } from "./StartHidden";
diff --git a/src/i18n/locales/ar/translation.json b/src/i18n/locales/ar/translation.json
index 026224d5..cb816a44 100644
--- a/src/i18n/locales/ar/translation.json
+++ b/src/i18n/locales/ar/translation.json
@@ -375,6 +375,15 @@
"fillerWordRemoval": {
"title": "إزالة كلمات الحشو",
"description": "يزيل كلمات التردد الشائعة من النصوص. عطّل هذا الخيار للاحتفاظ بها."
+ },
+ "chineseScript": {
+ "title": "الكتابة الصينية",
+ "description": "يكتب نصوص الماندرين والكانتونية بالأحرف المبسطة أو التقليدية. لا تتغير اللغات الأخرى.",
+ "options": {
+ "asTranscribed": "كما نُسخ",
+ "simplified": "مبسطة",
+ "traditional": "تقليدية"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/bg/translation.json b/src/i18n/locales/bg/translation.json
index f5170716..6c79810a 100644
--- a/src/i18n/locales/bg/translation.json
+++ b/src/i18n/locales/bg/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Премахване на думи паразити",
"description": "Премахва често срещаните думи за колебание от транскрипциите. Изключете, за да ги запазите."
+ },
+ "chineseScript": {
+ "title": "Китайска писменост",
+ "description": "Записва транскрипциите на мандарин и кантонски с опростени или традиционни йероглифи. Другите езици остават непроменени.",
+ "options": {
+ "asTranscribed": "Както е транскрибирано",
+ "simplified": "Опростени",
+ "traditional": "Традиционни"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/ca/translation.json b/src/i18n/locales/ca/translation.json
index 5d6ca034..4685baf6 100644
--- a/src/i18n/locales/ca/translation.json
+++ b/src/i18n/locales/ca/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Elimina les falques",
"description": "Elimina les expressions de vacil·lació habituals de les transcripcions. Desactiveu aquesta opció per conservar-les."
+ },
+ "chineseScript": {
+ "title": "Escriptura xinesa",
+ "description": "Escriu les transcripcions en mandarí i cantonès amb caràcters simplificats o tradicionals. Els altres idiomes no es modifiquen.",
+ "options": {
+ "asTranscribed": "Tal com s'ha transcrit",
+ "simplified": "Simplificat",
+ "traditional": "Tradicional"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/cs/translation.json b/src/i18n/locales/cs/translation.json
index 27da0ae3..a7e327c6 100644
--- a/src/i18n/locales/cs/translation.json
+++ b/src/i18n/locales/cs/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Odstranit výplňová slova",
"description": "Odstraňuje běžná slova vyjadřující váhání z přepisů. Vypnutím je zachováte."
+ },
+ "chineseScript": {
+ "title": "Čínské písmo",
+ "description": "Zapisuje přepisy v mandarínštině a kantonštině zjednodušenými nebo tradičními znaky. Ostatní jazyky zůstávají beze změny.",
+ "options": {
+ "asTranscribed": "Jak bylo přepsáno",
+ "simplified": "Zjednodušené",
+ "traditional": "Tradiční"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/da/translation.json b/src/i18n/locales/da/translation.json
index 162aa21d..10a0dd0d 100644
--- a/src/i18n/locales/da/translation.json
+++ b/src/i18n/locales/da/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Fjern fyldord",
"description": "Fjerner almindelige tøveord fra transskriptioner. Slå fra for at beholde dem."
+ },
+ "chineseScript": {
+ "title": "Kinesisk skrift",
+ "description": "Skriver mandarin- og kantonesisk-transskriptioner med forenklede eller traditionelle tegn. Andre sprog ændres ikke.",
+ "options": {
+ "asTranscribed": "Som transskriberet",
+ "simplified": "Forenklet",
+ "traditional": "Traditionel"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/de/translation.json b/src/i18n/locales/de/translation.json
index 1e4dc5ca..f159a774 100644
--- a/src/i18n/locales/de/translation.json
+++ b/src/i18n/locales/de/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Füllwörter entfernen",
"description": "Entfernt häufige Verzögerungslaute aus Transkriptionen. Deaktivieren Sie diese Option, um sie beizubehalten."
+ },
+ "chineseScript": {
+ "title": "Chinesische Schrift",
+ "description": "Schreibt Transkriptionen auf Mandarin und Kantonesisch in vereinfachten oder traditionellen Schriftzeichen. Andere Sprachen bleiben unverändert.",
+ "options": {
+ "asTranscribed": "Wie transkribiert",
+ "simplified": "Vereinfacht",
+ "traditional": "Traditionell"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json
index 4ddfdedc..440ebace 100644
--- a/src/i18n/locales/en/translation.json
+++ b/src/i18n/locales/en/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Remove Filler Words",
"description": "Removes common hesitation words from transcriptions. Turn off to keep them."
+ },
+ "chineseScript": {
+ "title": "Chinese Script",
+ "description": "Writes Mandarin and Cantonese transcriptions in Simplified or Traditional characters. Other languages are left unchanged.",
+ "options": {
+ "asTranscribed": "As Transcribed",
+ "simplified": "Simplified",
+ "traditional": "Traditional"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/es/translation.json b/src/i18n/locales/es/translation.json
index 2e10288d..9fb2be11 100644
--- a/src/i18n/locales/es/translation.json
+++ b/src/i18n/locales/es/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Eliminar muletillas",
"description": "Elimina las muletillas más comunes de las transcripciones. Desactívalo para conservarlas."
+ },
+ "chineseScript": {
+ "title": "Escritura china",
+ "description": "Escribe las transcripciones en mandarín y cantonés con caracteres simplificados o tradicionales. Los demás idiomas no se modifican.",
+ "options": {
+ "asTranscribed": "Tal como se transcribió",
+ "simplified": "Simplificado",
+ "traditional": "Tradicional"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/fr/translation.json b/src/i18n/locales/fr/translation.json
index fa71a955..d2a59048 100644
--- a/src/i18n/locales/fr/translation.json
+++ b/src/i18n/locales/fr/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Supprimer les mots de remplissage",
"description": "Supprime les hésitations courantes des transcriptions. Désactivez cette option pour les conserver."
+ },
+ "chineseScript": {
+ "title": "Écriture chinoise",
+ "description": "Écrit les transcriptions en mandarin et en cantonais en caractères simplifiés ou traditionnels. Les autres langues ne sont pas modifiées.",
+ "options": {
+ "asTranscribed": "Tel que transcrit",
+ "simplified": "Simplifié",
+ "traditional": "Traditionnel"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/he/translation.json b/src/i18n/locales/he/translation.json
index 54b33c0c..ecd43625 100644
--- a/src/i18n/locales/he/translation.json
+++ b/src/i18n/locales/he/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "הסרת מילות מילוי",
"description": "מסיר מילות היסוס נפוצות מתמלולים. השבת כדי להשאיר אותן."
+ },
+ "chineseScript": {
+ "title": "כתב סיני",
+ "description": "כותב תמלולים במנדרינית ובקנטונזית בתווים מפושטים או מסורתיים. שפות אחרות נשארות ללא שינוי.",
+ "options": {
+ "asTranscribed": "כפי שתומלל",
+ "simplified": "מפושט",
+ "traditional": "מסורתי"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/hi/translation.json b/src/i18n/locales/hi/translation.json
index 33fed79e..50b5041b 100644
--- a/src/i18n/locales/hi/translation.json
+++ b/src/i18n/locales/hi/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "फिलर शब्द हटाएं",
"description": "ट्रांसक्रिप्शन से आम हिचकिचाहट वाले शब्द हटाता है। उन्हें बनाए रखने के लिए इसे बंद करें।"
+ },
+ "chineseScript": {
+ "title": "चीनी लिपि",
+ "description": "मंदारिन और कैंटोनीज़ ट्रांसक्रिप्शन को सरलीकृत या पारंपरिक अक्षरों में लिखता है। अन्य भाषाएँ अपरिवर्तित रहती हैं।",
+ "options": {
+ "asTranscribed": "जैसा ट्रांसक्राइब हुआ",
+ "simplified": "सरलीकृत",
+ "traditional": "पारंपरिक"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/id/translation.json b/src/i18n/locales/id/translation.json
index 5b3edeee..43fc1d91 100644
--- a/src/i18n/locales/id/translation.json
+++ b/src/i18n/locales/id/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Hapus Kata Pengisi",
"description": "Menghapus kata pengisi umum dari transkripsi. Nonaktifkan untuk mempertahankannya."
+ },
+ "chineseScript": {
+ "title": "Aksara Tionghoa",
+ "description": "Menulis transkripsi Mandarin dan Kanton dengan aksara Sederhana atau Tradisional. Bahasa lain tidak diubah.",
+ "options": {
+ "asTranscribed": "Sesuai transkripsi",
+ "simplified": "Sederhana",
+ "traditional": "Tradisional"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/it/translation.json b/src/i18n/locales/it/translation.json
index 6f1a2c44..59a29f54 100644
--- a/src/i18n/locales/it/translation.json
+++ b/src/i18n/locales/it/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Rimuovi le parole riempitive",
"description": "Rimuove le parole di esitazione più comuni dalle trascrizioni. Disattiva per mantenerle."
+ },
+ "chineseScript": {
+ "title": "Scrittura cinese",
+ "description": "Scrive le trascrizioni in mandarino e cantonese con caratteri semplificati o tradizionali. Le altre lingue restano invariate.",
+ "options": {
+ "asTranscribed": "Come trascritto",
+ "simplified": "Semplificato",
+ "traditional": "Tradizionale"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/ja/translation.json b/src/i18n/locales/ja/translation.json
index ff05312b..ba02949b 100644
--- a/src/i18n/locales/ja/translation.json
+++ b/src/i18n/locales/ja/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "フィラー語を削除",
"description": "文字起こしから一般的なフィラー語を削除します。残すにはオフにしてください。"
+ },
+ "chineseScript": {
+ "title": "中国語の表記",
+ "description": "北京語と広東語の文字起こしを簡体字または繁体字で出力します。他の言語は変更されません。",
+ "options": {
+ "asTranscribed": "文字起こしのまま",
+ "simplified": "簡体字",
+ "traditional": "繁体字"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/ko/translation.json b/src/i18n/locales/ko/translation.json
index 942e3ced..8f5130bd 100644
--- a/src/i18n/locales/ko/translation.json
+++ b/src/i18n/locales/ko/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "군더더기 표현 제거",
"description": "전사에서 흔한 머뭇거림 표현을 제거합니다. 그대로 두려면 이 옵션을 끄세요."
+ },
+ "chineseScript": {
+ "title": "중국어 간체/번체",
+ "description": "표준 중국어와 광둥어 전사를 간체 또는 번체로 표기합니다. 다른 언어는 변경되지 않습니다.",
+ "options": {
+ "asTranscribed": "전사된 그대로",
+ "simplified": "간체",
+ "traditional": "번체"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/ne/translation.json b/src/i18n/locales/ne/translation.json
index de5fd212..c8949d65 100644
--- a/src/i18n/locales/ne/translation.json
+++ b/src/i18n/locales/ne/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "फिलर शब्दहरू हटाउनुहोस्",
"description": "ट्रान्सक्रिप्सनबाट सामान्य हिचकिचाहटका शब्दहरू हटाउँछ। तिनलाई राख्न यो विकल्प बन्द गर्नुहोस्।"
+ },
+ "chineseScript": {
+ "title": "चिनियाँ लिपि",
+ "description": "म्यान्डरिन र क्यान्टोनिज ट्रान्सक्रिप्सनलाई सरलीकृत वा परम्परागत अक्षरमा लेख्छ। अन्य भाषाहरू परिवर्तन हुँदैनन्।",
+ "options": {
+ "asTranscribed": "ट्रान्सक्राइब भए अनुसार",
+ "simplified": "सरलीकृत",
+ "traditional": "परम्परागत"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/nl/translation.json b/src/i18n/locales/nl/translation.json
index 51be3c50..c50e93fd 100644
--- a/src/i18n/locales/nl/translation.json
+++ b/src/i18n/locales/nl/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Opvulwoorden verwijderen",
"description": "Verwijdert veelvoorkomende aarzelwoorden uit transcripties. Schakel dit uit om ze te behouden."
+ },
+ "chineseScript": {
+ "title": "Chinees schrift",
+ "description": "Schrijft Mandarijn- en Kantonese transcripties in vereenvoudigde of traditionele karakters. Andere talen blijven ongewijzigd.",
+ "options": {
+ "asTranscribed": "Zoals getranscribeerd",
+ "simplified": "Vereenvoudigd",
+ "traditional": "Traditioneel"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/pl/translation.json b/src/i18n/locales/pl/translation.json
index 6d95b4cc..24d7ebeb 100644
--- a/src/i18n/locales/pl/translation.json
+++ b/src/i18n/locales/pl/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Usuń wyrazy wypełniające",
"description": "Usuwa typowe słowa wyrażające wahanie z transkrypcji. Wyłącz, aby je zachować."
+ },
+ "chineseScript": {
+ "title": "Pismo chińskie",
+ "description": "Zapisuje transkrypcje w języku mandaryńskim i kantońskim znakami uproszczonymi lub tradycyjnymi. Inne języki pozostają bez zmian.",
+ "options": {
+ "asTranscribed": "Jak w transkrypcji",
+ "simplified": "Uproszczone",
+ "traditional": "Tradycyjne"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/pt/translation.json b/src/i18n/locales/pt/translation.json
index 1ade6f0d..0932d46d 100644
--- a/src/i18n/locales/pt/translation.json
+++ b/src/i18n/locales/pt/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Remover palavras de preenchimento",
"description": "Remove hesitações comuns das transcrições. Desative para mantê-las."
+ },
+ "chineseScript": {
+ "title": "Escrita chinesa",
+ "description": "Escreve as transcrições em mandarim e cantonês com caracteres simplificados ou tradicionais. Os outros idiomas não são alterados.",
+ "options": {
+ "asTranscribed": "Como transcrito",
+ "simplified": "Simplificado",
+ "traditional": "Tradicional"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/ru/translation.json b/src/i18n/locales/ru/translation.json
index d655b151..6cf5fae5 100644
--- a/src/i18n/locales/ru/translation.json
+++ b/src/i18n/locales/ru/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Удалять слова-паразиты",
"description": "Удаляет распространённые слова-заминки из расшифровок. Отключите, чтобы сохранить их."
+ },
+ "chineseScript": {
+ "title": "Китайская письменность",
+ "description": "Записывает транскрипции на путунхуа и кантонском упрощёнными или традиционными иероглифами. Другие языки не изменяются.",
+ "options": {
+ "asTranscribed": "Как распознано",
+ "simplified": "Упрощённые",
+ "traditional": "Традиционные"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/sv/translation.json b/src/i18n/locales/sv/translation.json
index 3e554e46..2d29ec61 100644
--- a/src/i18n/locales/sv/translation.json
+++ b/src/i18n/locales/sv/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Ta bort utfyllnadsord",
"description": "Tar bort vanliga tvekljud från transkriberingar. Stäng av för att behålla dem."
+ },
+ "chineseScript": {
+ "title": "Kinesisk skrift",
+ "description": "Skriver mandarin- och kantonesiska transkriptioner med förenklade eller traditionella tecken. Andra språk lämnas oförändrade.",
+ "options": {
+ "asTranscribed": "Som transkriberat",
+ "simplified": "Förenklad",
+ "traditional": "Traditionell"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/tr/translation.json b/src/i18n/locales/tr/translation.json
index e809b5cf..343ccad4 100644
--- a/src/i18n/locales/tr/translation.json
+++ b/src/i18n/locales/tr/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Dolgu Sözcüklerini Kaldır",
"description": "Transkripsiyonlardaki yaygın duraksama sözcüklerini kaldırır. Bunları korumak için kapatın."
+ },
+ "chineseScript": {
+ "title": "Çince yazı",
+ "description": "Mandarin ve Kantonca transkripsiyonları Basitleştirilmiş veya Geleneksel karakterlerle yazar. Diğer diller değiştirilmez.",
+ "options": {
+ "asTranscribed": "Transkripsiyondaki gibi",
+ "simplified": "Basitleştirilmiş",
+ "traditional": "Geleneksel"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/uk/translation.json b/src/i18n/locales/uk/translation.json
index 8ee3c8a3..ab37f686 100644
--- a/src/i18n/locales/uk/translation.json
+++ b/src/i18n/locales/uk/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Видаляти слова-паразити",
"description": "Видаляє поширені слова-вагання з транскрипцій. Вимкніть, щоб зберегти їх."
+ },
+ "chineseScript": {
+ "title": "Китайська писемність",
+ "description": "Записує транскрипції мандаринською та кантонською спрощеними або традиційними ієрогліфами. Інші мови не змінюються.",
+ "options": {
+ "asTranscribed": "Як розпізнано",
+ "simplified": "Спрощені",
+ "traditional": "Традиційні"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/vi/translation.json b/src/i18n/locales/vi/translation.json
index c0e5d04a..554c4002 100644
--- a/src/i18n/locales/vi/translation.json
+++ b/src/i18n/locales/vi/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "Loại bỏ từ đệm",
"description": "Loại bỏ các từ ngập ngừng phổ biến khỏi bản chép lời. Tắt để giữ lại các từ này."
+ },
+ "chineseScript": {
+ "title": "Chữ Hán giản thể/phồn thể",
+ "description": "Ghi bản chép tiếng Quan Thoại và tiếng Quảng Đông bằng chữ Giản thể hoặc Phồn thể. Các ngôn ngữ khác không bị thay đổi.",
+ "options": {
+ "asTranscribed": "Giữ nguyên bản chép",
+ "simplified": "Giản thể",
+ "traditional": "Phồn thể"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/zh-TW/translation.json b/src/i18n/locales/zh-TW/translation.json
index 4eb969ec..2bcba311 100644
--- a/src/i18n/locales/zh-TW/translation.json
+++ b/src/i18n/locales/zh-TW/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "移除語助詞",
"description": "從轉錄中移除常見的語助詞。關閉此選項即可保留這些詞。"
+ },
+ "chineseScript": {
+ "title": "繁簡轉換",
+ "description": "將國語和粵語轉錄輸出為簡體或繁體中文。其他語言不受影響。",
+ "options": {
+ "asTranscribed": "保持原樣",
+ "simplified": "簡體",
+ "traditional": "繁體"
+ }
}
},
"postProcessing": {
diff --git a/src/i18n/locales/zh/translation.json b/src/i18n/locales/zh/translation.json
index 36c971e9..b8ec5dcd 100644
--- a/src/i18n/locales/zh/translation.json
+++ b/src/i18n/locales/zh/translation.json
@@ -398,6 +398,15 @@
"fillerWordRemoval": {
"title": "移除语气词",
"description": "从转录中移除常见的语气词。关闭此选项即可保留这些词。"
+ },
+ "chineseScript": {
+ "title": "简繁转换",
+ "description": "将普通话和粤语转录输出为简体或繁体中文。其他语言不受影响。",
+ "options": {
+ "asTranscribed": "保持原样",
+ "simplified": "简体",
+ "traditional": "繁体"
+ }
}
},
"postProcessing": {
diff --git a/src/lib/constants/languages.ts b/src/lib/constants/languages.ts
index 44170b42..323d8e99 100644
--- a/src/lib/constants/languages.ts
+++ b/src/lib/constants/languages.ts
@@ -3,8 +3,6 @@ export interface Language {
label: string;
}
-export const CHINESE_LANGUAGE_CODE = "zh";
-
const LANGUAGE_ALIASES = new Map([
["nb", "no"],
["fil", "tl"],
@@ -13,9 +11,7 @@ const LANGUAGE_ALIASES = new Map([
export const LANGUAGES: Language[] = [
{ value: "auto", label: "Auto Detect" },
{ value: "en", label: "English" },
- { value: CHINESE_LANGUAGE_CODE, label: "Chinese" },
- { value: "zh-Hans", label: "Chinese (Simplified)" },
- { value: "zh-Hant", label: "Chinese (Traditional)" },
+ { value: "zh", label: "Chinese (Mandarin)" },
{ value: "yue", label: "Cantonese" },
{ value: "de", label: "German" },
{ value: "es", label: "Spanish" },
@@ -117,26 +113,12 @@ export const LANGUAGES: Language[] = [
{ value: "su", label: "Sundanese" },
];
-const CHINESE_OUTPUT_INTENTS = new Set(["zh-Hans", "zh-Hant"]);
-
const LANGUAGE_LABELS = new Map(
LANGUAGES.map((language) => [language.value, language.label] as const),
);
export const MODEL_CAPABILITY_LANGUAGES: Language[] = LANGUAGES.filter(
- (language) =>
- language.value !== "auto" && !CHINESE_OUTPUT_INTENTS.has(language.value),
-);
-
-// Languages offered in the transcription-language picker. We surface the two
-// explicit Chinese *output* variants (Simplified / Traditional) and hide the
-// bare recognition code `zh` ("Chinese"): all three recognize identically, so
-// the plain option only adds ambiguity about which script you get. `zh` stays in
-// LANGUAGES — it's still a valid *effective* language (auto-detect and must-pick
-// fallback can resolve to it) and its label is needed to render that state — it
-// just isn't directly selectable.
-export const SELECTABLE_LANGUAGES: Language[] = LANGUAGES.filter(
- (language) => language.value !== CHINESE_LANGUAGE_CODE,
+ (language) => language.value !== "auto",
);
// Collapse a language tag to the canonical recognition intent Handy exposes in
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index fbbf5193..b3a6de61 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -4,6 +4,7 @@ import { listen } from "@tauri-apps/api/event";
import type {
AppSettings as Settings,
AudioDevice,
+ ChineseScript,
TranscribeAcceleratorSetting,
OrtAcceleratorSetting,
ShortcutActivation,
@@ -182,6 +183,8 @@ const settingUpdaters: {
},
filler_word_removal_enabled: (value) =>
commands.changeFillerWordRemovalEnabledSetting(value as boolean),
+ chinese_script: (value) =>
+ commands.changeChineseScriptSetting(value as ChineseScript),
show_tray_icon: (value) =>
commands.changeShowTrayIconSetting(value as boolean),
transcribe_accelerator: (value) =>