aboutsummaryrefslogtreecommitdiff
path: root/src/args.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-06-20 20:11:52 +0800
committer魏曹先生 <1992414357@qq.com>2026-06-20 20:11:52 +0800
commitdbeac25149b52a6a069ad29dd75204c8953b365c (patch)
tree51deb16eafde53273b6b89f4a0da06c87982c4f5 /src/args.rs
parent90595bbed2b0fdfda45980dc7ebff8c4eb11dcbd (diff)
feat: add pinyin conversion for Chinese output
Diffstat (limited to 'src/args.rs')
-rw-r--r--src/args.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/args.rs b/src/args.rs
index 679d8e1..11a1f11 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -117,6 +117,10 @@ pub struct DMVOPArguments {
require_equals = true
)]
pub subnet_mask: String,
+
+ // Convert text output to pinyin (Chinese romanization)
+ #[arg(long = "pinyin")]
+ pub use_pinyin: bool,
}
#[derive(Clone, Debug)]
@@ -178,6 +182,16 @@ pub fn format_output(pattern: &str, word: &str, confidence: f32, volume: f32) ->
result
}
+/// Convert transcribed text to pinyin if the `use_pinyin` flag is set.
+/// Otherwise returns the original text as a String.
+pub fn maybe_to_pinyin(text: &str, use_pinyin: bool) -> String {
+ if use_pinyin {
+ pinyin::to_pinyin_vec(text, pinyin::Pinyin::plain).join(" ")
+ } else {
+ text.to_string()
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;