Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions apps/mofa-asr/src/screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,27 @@ impl Widget for MoFaASRScreen {
if self.paraformer_chat_controller.is_none() {
let controller = ChatController::new_arc();
{
let mut guard = controller.lock().expect("ChatController mutex poisoned");
let mut guard = match controller.lock() {
Ok(g) => g,
Err(poisoned) => {
::log::warn!("ChatController mutex poisoned; recovering inner state");
poisoned.into_inner()
}
};
guard.dangerous_state_mut().bots.push(Bot {
id: BotId::new("asr"),
name: "Paraformer".to_string(),
avatar: EntityAvatar::Text("P".to_string()),
capabilities: BotCapabilities::new(),
});
}
self.paraformer_chat_controller = Some(controller.clone());
self.paraformer_chatmatch controller.lock() {
Ok(g) => g,
Err(poisoned) => {
::log::warn!("ChatController mutex poisoned; recovering inner state");
poisoned.into_inner()
}
}
self.view.messages(ids!(paraformer_messages)).write().chat_controller = Some(controller);
}
if self.qwen3_chat_controller.is_none() {
Expand Down Expand Up @@ -423,7 +435,13 @@ impl MoFaASRScreen {
};

let count = {
let mut guard = controller.lock().expect("ChatController mutex poisoned");
let mut guard = match controller.lock() {
Ok(g) => g,
Err(poisoned) => {
::log::warn!("ChatController mutex poisoned; recovering inner state");
poisoned.into_inner()
}
};
let state = guard.dangerous_state_mut();
state.messages.clear();
for msg in messages {
Expand Down Expand Up @@ -465,7 +483,14 @@ impl MoFaASRScreen {
fn handle_start(&mut self, cx: &mut Cx) {
// Clear per-engine chat controllers
if let Some(ref controller) = self.paraformer_chat_controller {
controller.lock().expect("ChatController mutex poisoned").dangerous_state_mut().messages.clear();
let mut guard = match controller.lock() {
Ok(g) => g,
Err(poisoned) => {
::log::warn!("ChatController mutex poisoned; recovering inner state");
poisoned.into_inner()
}
};
guard.dangerous_state_mut().messages.clear();
}
if let Some(ref controller) = self.qwen3_chat_controller {
controller.lock().expect("ChatController mutex poisoned").dangerous_state_mut().messages.clear();
Expand Down
2 changes: 1 addition & 1 deletion doc/CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ pub enum TabId {
- [x] Simplified code: `contains(&TabId::Profile)` instead of `iter().any(|t| t == "profile")`

**Benefits**:
- Compile-time checking prevents typos like `"profiel"` or `"setings"`
- Compile-time checking prevents typos like `"profiel"` or `"settgs"`
- IDE autocomplete works with enum variants
- Exhaustive match ensures all cases handled
- `Copy` trait allows efficient passing without `.clone()` or `.to_string()`
Expand Down
3 changes: 2 additions & 1 deletion mofa-dora-bridge/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ nodes:
tts_log: tts/log
"#;

let parsed = DataflowParser::parse_string(yaml, PathBuf::from("test.yml")).unwrap();
let parsed = DataflowParser::parse_string(yaml, PathBuf::from("test.yml"))
.expect("DataflowParser failed to parse a valid test YAML; check parser changes");

assert_eq!(parsed.mofa_nodes.len(), 2);
assert_eq!(parsed.mofa_nodes[0].id, "mofa-audio-player");
Expand Down
9 changes: 8 additions & 1 deletion node-hub/dora-funasr-nano-mlx/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ fn main() -> Result<()> {
}
}

let engine = engine.as_mut().unwrap();
let engine = match engine.as_mut() {
Some(e) => e,
None => {
log::error!("Engine unexpectedly missing after attempted initialization");
send_log(&mut node, "ERROR", "Engine not available")?;
continue;
}
};

// Extract metadata
let question_id = metadata
Expand Down
3 changes: 2 additions & 1 deletion node-hub/dora-gpt-sovits-mlx/src/ssml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ mod tests {

#[test]
fn test_plain_text() {
let result = parse_ssml("<speak>hello world</speak>").unwrap();
let result = parse_ssml("<speak>hello world</speak>")
.expect("parse_ssml should parse simple <speak> content");
assert_eq!(result, vec![SsmlSegment::Text {
text: "hello world".to_string(),
speed: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,20 @@ def get_namedict():


def text_normalize(text):
# todo: eng text normalize
# 适配中文及 g2p_en 标点
if not text:
return ""

# ensure string
text = str(text)

# punctuation compatibility (smart quotes, dashes, ellipsis, CJK punctuation)
rep_map = {
"[;::,;]": ",",
'["’]': "'",
"[\\u2018\\u2019`‘’]": "'",
"[\\u201c\\u201d\\u00ab\\u00bb\\u201e\\\"]": '"',
"\\u2026": "...",
"[\\u2013\\u2014]": "-",
"。": ".",
"!": "!",
"?": "?",
Expand All @@ -233,16 +242,36 @@ def text_normalize(text):

# 来自 g2p_en 文本格式化处理
# 增加大写兼容
text = unicode(text)
text = normalize_numbers(text)
text = ''.join(char for char in unicodedata.normalize('NFD', text)
if unicodedata.category(char) != 'Mn') # Strip accents
text = re.sub("[^ A-Za-z'.,?!\-]", "", text)
text = re.sub(r"(?i)i\.e\.", "that is", text)
text = re.sub(r"(?i)e\.g\.", "for example", text)
try:
text = normalize_numbers(text)
except Exception:
pass

# strip accents
text = "".join(
ch for ch in unicodedata.normalize('NFD', text)
if unicodedata.category(ch) != 'Mn'
)

# keep letters, digits, quotes/apostrophes, basic punctuation and hyphen
text = re.sub(r"[^ 0-9a-z'\".,?!\-]", "", text)

# expand abbreviations (word boundaries, case-insensitive)
text = re.sub(r"\bi\.e\.\b", "that is", text, flags=re.IGNORECASE)
text = re.sub(r"\be\.g\.\b", "for example", text, flags=re.IGNORECASE)

# 避免重复标点引起的参考泄露
text = replace_consecutive_punctuation(text)
try:
text = replace_consecutive_punctuation(text)
except Exception:
text = re.sub(r"([.,?!\-])\1+", r"\1", text)

# normalize whitespace
text = re.sub(r"\s+", " ", text).strip()

# ensure terminal punctuation for TTS stability
if text and text[-1] not in ".?!":
text += "."

return text

Expand Down