You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is_placeholder_heading added and correctly detects strings made only of # (including ##, ###, and whitespace-padded variants) while rejecting C#, # 你好, #hash, empty, and whitespace-only text.
The check is applied in the non-verbose branch of transcribe_chunk and in the no-segments fallback of extract_confident_text; matches are normalized to empty strings and reuse the existing empty-transcript guard.
Multi-chunk placeholder chunks are dropped while real chunks are preserved (["你好", "#", "世界"] -> 你好世界).
Four unit tests were added covering the required placeholder scenarios and normal-content preservation.
Non-compliant requirements:
None
Requires further human verification:
Whether GLM-ASR in verbose_json mode can return a segments array containing a pure-# segment. The new filter is only applied to the whole text field and to the no-segments fallback, not to individual segments in the extract_confident_text loop, so runtime verification with GLM-ASR is needed to confirm this path cannot leak placeholders.
The placeholder filter is applied only to the whole-text path (non-verbose branch) and to the no-segments fallback in extract_confident_text. When verbose_json is enabled and the response contains a segments array, segment texts are still concatenated as before, so a segment whose text is pure # (the issue #787 placeholder) is kept whenever it passes the compression_ratio/avg_logprob heuristics, or kept unconditionally if the provider omits those metadata fields (missing metadata is treated as "don't discard"). In that path the placeholder would still reach user input, which is the exact bug this PR targets. Consider filtering pure-# segment texts inside the loop or normalizing the final kept string; whether GLM-ASR actually returns such segments in verbose mode needs runtime confirmation.
let text = json["text"].as_str().unwrap_or("").trim();ifis_placeholder_heading(text){returnString::new();}return text.to_string();};letmut kept = String::new();for seg in segments {let text = seg.get("text").and_then(|t| t.as_str()).unwrap_or("");if text.trim().is_empty(){continue;}let no_speech = seg
.get("no_speech_prob").and_then(|v| v.as_f64()).unwrap_or(0.0);let avg_logprob = seg
.get("avg_logprob").and_then(|v| v.as_f64()).unwrap_or(0.0);let compression = seg
.get("compression_ratio").and_then(|v| v.as_f64()).unwrap_or(1.0);let is_hallucination =
(no_speech > 0.6 && avg_logprob < -0.5) || compression > 2.4 || avg_logprob < -1.0;if is_hallucination {
log::warn!("[whisper] 丢弃疑似幻听段落: no_speech={:.2} avg_logprob={:.2} compression={:.2} text={:?}",
no_speech,
avg_logprob,
compression,
text.trim());continue;}
kept.push_str(text);}let kept = kept.trim().to_string();if kept.is_empty(){// 全部段落被判为幻听(≈整段几乎是静音)。回退到原始 text 会把幻听又捡// 回来,所以返回空串;上层把空转写当「什么都没说」无害处理。returnString::new();}
kept
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
main 上 #916 的 hotfix(直接合入 main,绕过 beta 流程)补进 beta:正式版发布前保持两条分支一致,避免 beta 后续版本缺失 GLM-ASR 纯井号过滤。cherry-pick 后 cargo check 通过。
PR Type
Bug fix, Tests
Description
Filter GLM-ASR pure
#placeholder transcriptions.Normalize placeholder chunks to empty transcripts, reusing the existing empty guard.
Apply normalization in both normal and confident-text fallback paths.
Add unit tests for single, mixed, and all-placeholder chunk scenarios.
Diagram Walkthrough
flowchart LR A["ASR response text"] --> B{"Pure # placeholder?"} B -- "yes" --> C["Empty transcript"] B -- "no" --> D["Normal transcript"] C --> E["Existing empty guard"]File Walkthrough
whisper.rs
Filter pure hash placeholders in ASR transcriptionopenless-all/app/src-tauri/src/asr/whisper.rs
is_placeholder_headingto detect text consisting only of#characters.
transcribe_chunkandextract_confident_text.C#and# 你好.