pi-voice-input 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ Typing long prompts can slow you down. `pi-voice-input` lets you:
20
20
  - **Chinese/English mixed input**: handles prompts that switch between Chinese, English, product names, and technical terms.
21
21
  - **Works on Linux and macOS**: uses common system recording tools.
22
22
  - **Lowers sound while you speak**: automatically turns down system audio during recording, then restores it afterwards.
23
- - **No hidden rewriting**: inserts the raw ASR transcript, prefixed with a short note that it may contain voice-recognition errors.
23
+ - **No hidden rewriting**: inserts the raw ASR transcript, prefixed with a short note that it may contain voice-recognition errors. If the editor already contains that note, later dictation inserts only the transcript.
24
24
  - **Simple setup commands**: configure from inside pi with `/voice init` and `/voice key`.
25
25
 
26
26
  Current speech provider: **VolcEngine Speech ASR**. A VolcEngine Speech API key is required.
@@ -98,7 +98,7 @@ Useful commands:
98
98
 
99
99
  ## Inserted text format
100
100
 
101
- The extension does not call a model to modify or translate your transcript. It inserts a short caveat telling the downstream model that the following text came from voice input and may contain recognition errors, then appends the raw ASR transcript unchanged.
101
+ The extension does not call a model to modify or translate your transcript. It inserts a concise, location-neutral caveat saying the current conversation may include voice transcription errors, asking the model to correct them from context or ask the user if the meaning is unclear, then appends the raw ASR transcript unchanged. When you dictate multiple times in the same unsent editor draft, the caveat is kept to a single copy.
102
102
 
103
103
  User config keys are:
104
104
 
@@ -26,11 +26,7 @@ const VOLC_API_KEY_URL = "https://console.volcengine.com/speech/new/setting/apik
26
26
  // the local machine, so force those subprocesses to a known-local cwd.
27
27
  const LOCAL_AUDIO_PROCESS_CWD = homedir();
28
28
  const DEFAULT_SHORTCUT = Key.ctrlShift("r");
29
- const VOICE_TRANSCRIPT_NOTICE = [
30
- "以下内容来自用户通过语音输入的原始转写,可能包含语音识别错误、错别字、同音词、断句或标点不准确,以及中英文、术语、代码名、文件名误识别等问题。",
31
- "请明确注意:这段转写不一定完全准确。请结合上下文理解用户意图;必要时可以先澄清、翻译或推断,再继续处理。",
32
- "原始语音转写如下:",
33
- ].join("\n");
29
+ const VOICE_TRANSCRIPT_NOTICE = "当前会话中的内容包含语音转写,可能存在识别错误;请结合上下文纠正,若不确定或明显偏离主题无法理解,请先询问用户。";
34
30
 
35
31
  const MSG_TYPE_CLIENT_FULL_REQUEST = 0b0001;
36
32
  const MSG_TYPE_CLIENT_AUDIO_ONLY_REQUEST = 0b0010;
@@ -928,9 +924,14 @@ async function transcribePcm(pcm: Buffer, durationMs: number, config: VoiceConfi
928
924
  };
929
925
  }
930
926
 
931
- function wrapVoiceTranscript(rawText: string): string {
927
+ function editorHasVoiceTranscriptNotice(editorText: string): boolean {
928
+ return editorText.replace(/\r\n/g, "\n").includes(VOICE_TRANSCRIPT_NOTICE);
929
+ }
930
+
931
+ function wrapVoiceTranscript(rawText: string, currentEditorText = ""): string {
932
932
  const trimmed = rawText.trim();
933
933
  if (!trimmed) return "";
934
+ if (editorHasVoiceTranscriptNotice(currentEditorText)) return trimmed;
934
935
  return `${VOICE_TRANSCRIPT_NOTICE}
935
936
 
936
937
  ${trimmed}`;
@@ -1084,7 +1085,7 @@ async function stopRecording(ctx: ExtensionContext, transcribe = true) {
1084
1085
  return;
1085
1086
  }
1086
1087
 
1087
- const finalText = wrapVoiceTranscript(result.text);
1088
+ const finalText = wrapVoiceTranscript(result.text, ctx.ui.getEditorText());
1088
1089
 
1089
1090
  ctx.ui.setStatus("voice-input", undefined);
1090
1091
  insertIntoEditor(ctx, finalText);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-voice-input",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Press Ctrl+Shift+R to dictate prompts into Pi using VolcEngine ASR",
5
5
  "type": "module",
6
6
  "keywords": [