In order to be able to use Chinese within rerun Chinese characters are converted to pinyin See: https://github.com/dora-rs/dora/issues/1039tags/v0.3.12-fix
| @@ -3360,6 +3360,7 @@ dependencies = [ | |||||
| "eyre", | "eyre", | ||||
| "k", | "k", | ||||
| "ndarray 0.15.6", | "ndarray 0.15.6", | ||||
| "pinyin", | |||||
| "pyo3", | "pyo3", | ||||
| "rand 0.9.1", | "rand 0.9.1", | ||||
| "rerun", | "rerun", | ||||
| @@ -8451,6 +8452,12 @@ version = "0.1.0" | |||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" | ||||
| [[package]] | |||||
| name = "pinyin" | |||||
| version = "0.10.0" | |||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | |||||
| checksum = "16f2611cd06a1ac239a0cea4521de9eb068a6ca110324ee00631aa68daa74fc0" | |||||
| [[package]] | [[package]] | ||||
| name = "piper" | name = "piper" | ||||
| version = "0.2.4" | version = "0.2.4" | ||||
| @@ -28,7 +28,7 @@ nodes: | |||||
| # USE_MODELSCOPE_HUB: true | # USE_MODELSCOPE_HUB: true | ||||
| - id: dora-rerun | - id: dora-rerun | ||||
| build: cargo build -p dora-rerun --release | |||||
| build: pip install -e ../../node-hub/dora-rerun | |||||
| path: dora-rerun | path: dora-rerun | ||||
| inputs: | inputs: | ||||
| original_text: dora-distil-whisper/text | original_text: dora-distil-whisper/text | ||||
| @@ -28,6 +28,7 @@ pyo3 = { workspace = true, features = [ | |||||
| ], optional = true } | ], optional = true } | ||||
| bytemuck = "1.20.0" | bytemuck = "1.20.0" | ||||
| rand = "0.9.1" | rand = "0.9.1" | ||||
| pinyin = "0.10.0" | |||||
| [lib] | [lib] | ||||
| @@ -12,6 +12,7 @@ use dora_node_api::{ | |||||
| }; | }; | ||||
| use eyre::{bail, eyre, Context, Result}; | use eyre::{bail, eyre, Context, Result}; | ||||
| use pinyin::ToPinyin; | |||||
| use rerun::{ | use rerun::{ | ||||
| components::ImageBuffer, external::log::warn, ImageFormat, Points2D, Points3D, SpawnOptions, | components::ImageBuffer, external::log::warn, ImageFormat, Points2D, Points3D, SpawnOptions, | ||||
| }; | }; | ||||
| @@ -315,7 +316,24 @@ pub fn lib_main() -> Result<()> { | |||||
| let buffer: StringArray = data.to_data().into(); | let buffer: StringArray = data.to_data().into(); | ||||
| buffer.iter().try_for_each(|string| -> Result<()> { | buffer.iter().try_for_each(|string| -> Result<()> { | ||||
| if let Some(str) = string { | if let Some(str) = string { | ||||
| rec.log(id.as_str(), &rerun::TextLog::new(str)) | |||||
| let chars = str.chars().collect::<Vec<_>>(); | |||||
| let mut new_string = vec![]; | |||||
| for char in chars { | |||||
| // Check if the character is a Chinese character | |||||
| if char.is_ascii() || char.is_control() { | |||||
| new_string.push(char); | |||||
| continue; | |||||
| } | |||||
| // If it is a Chinese character, replace it with its pinyin | |||||
| if let Some(pinyin) = char.to_pinyin() { | |||||
| for char in pinyin.with_tone().chars() { | |||||
| new_string.push(char); | |||||
| } | |||||
| new_string.push(' '); | |||||
| } | |||||
| } | |||||
| let pinyined_str = new_string.iter().collect::<String>(); | |||||
| rec.log(id.as_str(), &rerun::TextLog::new(pinyined_str)) | |||||
| .wrap_err("Could not log text") | .wrap_err("Could not log text") | ||||
| } else { | } else { | ||||
| Ok(()) | Ok(()) | ||||