@goodandready/dsh-voice 0.9.51 → 0.9.53
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/lib/client.js +245 -136
- package/lib/dictation-modes.js +6 -3
- package/lib/normalize.js +121 -2
- package/lib/schema.js +4 -1
- package/lib/transcribe-core.js +6 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -18,38 +18,38 @@ const PKG = '@goodandready/dsh-voice'
|
|
|
18
18
|
const ROW_ID = 'dsh-voice'
|
|
19
19
|
const ROW_CONFIG_KEY = PKG + '#' + ROW_ID
|
|
20
20
|
const en = {
|
|
21
|
-
'saveFailed':'Some fields were not saved —', 'cardHint':'Dictation and voice
|
|
21
|
+
'saveFailed':'Some fields were not saved —', 'cardHint':'Dictation and voice input settings',
|
|
22
22
|
'expand':'Expand', 'collapse':'Collapse', 'composerUnavailable':'Composer unavailable', 'keySpace':'Space', 'keyUnset':'not set',
|
|
23
|
-
'recognitionError':'recognition failed', 'micUnavailable':'
|
|
24
|
-
'noRecorder':'MediaRecorder
|
|
23
|
+
'recognitionError':'recognition failed', 'micUnavailable':'Mic unavailable: needs HTTPS or localhost',
|
|
24
|
+
'noRecorder':'MediaRecorder unsupported in browser', 'browserFailed':'Browser did not recognize: ',
|
|
25
25
|
'nothingHeard':'Nothing was recognized', 'dictationBtn':'Voice typing', 'messageBtn':'Voice message — click or hold',
|
|
26
26
|
'dictationPill':'Dictation — text is appended to the input', 'messagePill':'Recording a voice message', 'cancel':'Cancel',
|
|
27
27
|
'holdHint':'Hold — release to send', 'listening':'Listening in the browser…', 'stop':'Stop', 'transcribing':'Transcribing…',
|
|
28
28
|
'sendingIn':'Sending to the agent in', 'secondsShort':' s', 'keepPending':'Do not send', 'hide':'Hide', 'title':'Voice',
|
|
29
29
|
'recordSlot':'Voice recording',
|
|
30
|
-
'browserHint':'Web Speech recognition (uses
|
|
30
|
+
'browserHint':'Web Speech recognition (uses browser language; Chrome sends audio to Google)',
|
|
31
31
|
'browserWebGpu':'Browser WebGPU Whisper (Offline)',
|
|
32
|
-
'browserWebGpuHint':'Runs Whisper
|
|
33
|
-
'npuProvider':'Hardware Acceleration
|
|
34
|
-
'npuProviderHint':'
|
|
32
|
+
'browserWebGpuHint':'Runs Whisper directly in browser GPU: offline, zero network traffic.',
|
|
33
|
+
'npuProvider':'Hardware Acceleration',
|
|
34
|
+
'npuProviderHint':'SenseVoice hardware provider: CPU, Rockchip NPU, OpenVINO, or CUDA.',
|
|
35
35
|
'npuThreads':'Threads (CPU/SBC)', 'benchmarkTitle':'Hardware Benchmark (Speed & Latency)', 'runBenchmarkBtn':'Run Benchmark',
|
|
36
36
|
'benchmarking':'Running benchmark…',
|
|
37
|
-
'benchmarkHint':'Measures
|
|
38
|
-
'webgpuStatus':'Browser WebGPU Status', 'webgpuAvailable':'WebGPU Available (
|
|
39
|
-
'webgpuNotAvailable':'WebGPU Not Detected (
|
|
40
|
-
'siliconflowHint':'FunAudioLLM/SenseVoiceSmall
|
|
41
|
-
'deepinfraHint':'openai/whisper-large-v3-turbo
|
|
42
|
-
'mistralHint':'voxtral-mini-latest
|
|
37
|
+
'benchmarkHint':'Measures RTF and inference latency on 1.0s audio sample.',
|
|
38
|
+
'webgpuStatus':'Browser WebGPU Status', 'webgpuAvailable':'WebGPU Available (ready)',
|
|
39
|
+
'webgpuNotAvailable':'WebGPU Not Detected (server fallback)', 'openaiHint':'whisper-1 · key OPENAI_API_KEY',
|
|
40
|
+
'siliconflowHint':'FunAudioLLM/SenseVoiceSmall',
|
|
41
|
+
'deepinfraHint':'openai/whisper-large-v3-turbo', 'fireworksHint':'whisper-v3-turbo',
|
|
42
|
+
'mistralHint':'voxtral-mini-latest', 'openrouterHint':'google/gemini-2.5-flash',
|
|
43
43
|
'localHint':'set when the server is started', 'up':'Up', 'down':'Down', 'remove':'Remove', 'addProvider':'Add provider',
|
|
44
44
|
'chainHint':'Top to bottom is the order they are tried in', 'customName':'name used in the chain', 'customModel':'model',
|
|
45
|
-
'customKeyName':'key name', 'customModelHint':'model to request (empty
|
|
45
|
+
'customKeyName':'key name', 'customModelHint':'model to request (empty = default)', 'addCustom':'Add your own provider',
|
|
46
46
|
'loadingSettings':'Loading settings…',
|
|
47
|
-
'notReady1':'
|
|
48
|
-
'notReady2':'
|
|
49
|
-
'clearKey':'Clear the key', 'hotkeyHint1':'Hold
|
|
50
|
-
'hotkeyHint2':'Any
|
|
47
|
+
'notReady1':'Settings not ready yet. If just restarted, ',
|
|
48
|
+
'notReady2':'it will appear shortly.', 'hotkey':'Voice message key', 'pressKey':'Press a key…',
|
|
49
|
+
'clearKey':'Clear the key', 'hotkeyHint1':'Hold to record, release to send, Esc cancels. ',
|
|
50
|
+
'hotkeyHint2':'Any letter, F-key or modifier.', 'language':'Language', 'langAuto':'Auto-detect',
|
|
51
51
|
'langRu':'Russian (ru)', 'langEn':'English (en)', 'langZh':'Chinese (zh)', 'langUk':'Ukrainian (uk)', 'langDe':'German (de)',
|
|
52
|
-
'dictationHint':'Speech is
|
|
52
|
+
'dictationHint':'Speech is chunked at pauses into the input.', 'pauseMs':'Pause that ends a phrase, ms',
|
|
53
53
|
'pauseHint':'Lower means more frequent chunks and faster text, but a higher risk of cutting a word', 'speaking':'You are speaking…',
|
|
54
54
|
'silence':'Pause…', 'normalizeTranscript':'Normalize file transcripts', 'undo':'Undo last insert', 'undone':'Insert undone',
|
|
55
55
|
'nothingToUndo':'Nothing to undo', 'clipping':'Clipping', 'clippingHint':'Too loud (clipping)', 'lowVolume':'Low signal',
|
|
@@ -68,7 +68,7 @@ const en = {
|
|
|
68
68
|
'editablePreviewHint':'Show recognized text before sending with editing, comparison and abort options.', 'editPreview':'Edit',
|
|
69
69
|
'sendNow':'Send', 'cancelPreview':'Cancel', 'rawText':'Raw', 'polishedText':'Polished',
|
|
70
70
|
'sessionMismatch':'Different chat active; canceled to prevent leak.', 'sessionCommands':'Voice session commands',
|
|
71
|
-
'sessionCommandsHint':'
|
|
71
|
+
'sessionCommandsHint':'Commands act on session instead of being inserted as text',
|
|
72
72
|
'polishBaseUrl':'Offline polish endpoint',
|
|
73
73
|
'polishBaseUrlHint':'OpenAI-compatible /chat/completions base URL, e.g. a local Ollama. Empty = harness model',
|
|
74
74
|
'polishModel':'Offline polish model', 'polishKeyEnv':'Offline polish key credential',
|
|
@@ -79,15 +79,15 @@ const en = {
|
|
|
79
79
|
'customHint':'Any OpenAI-compatible API. The name becomes available in the chains above.', 'general':'General',
|
|
80
80
|
'whisperEndpoint':'Local whisper: endpoint', 'whisperEndpointHint':'POST /inference of a whisper.cpp server',
|
|
81
81
|
'deepgramEndpoint':'Deepgram: base URL',
|
|
82
|
-
'deepgramEndpointHint':'Base URL for Deepgram
|
|
82
|
+
'deepgramEndpointHint':'Base URL for Deepgram API (default https://api.deepgram.com)',
|
|
83
83
|
'whisperBin':'Local whisper: binary', 'whisperBinHint':'used when autostart is on', 'whisperModel':'Local whisper: model',
|
|
84
84
|
'whisperModelHint':'Absolute path to the ggml model file', 'whisperAutostart':'Autostart the local whisper',
|
|
85
85
|
'bilingualDeveloperPrompt':'Bilingual developer context (RU/EN)',
|
|
86
|
-
'bilingualDeveloperPromptHint':'
|
|
86
|
+
'bilingualDeveloperPromptHint':'Hints dev terms & CLI to STT to prevent phonetic transliteration',
|
|
87
87
|
'calibrateNoise':'Calibrate Noise (2s)',
|
|
88
88
|
'calibrateNoiseHint':'Measure room noise for 2 seconds and auto-set the optimal noise gate threshold', 'calibrating':'Measuring noise…',
|
|
89
89
|
'calibratedMsg':'Gate set: {db} dB (ambient: {noise} dB)', 'calibratedValue':'Calibrated', 'save':'Save', 'saved':'Saved ✓',
|
|
90
|
-
'openrouterWarning':'OpenRouter
|
|
90
|
+
'openrouterWarning':'OpenRouter lacks /audio/transcriptions — use openai-chat-audio template',
|
|
91
91
|
'noiseSuppression':'Hardware noise suppression',
|
|
92
92
|
'noiseSuppressionHint':'Enable browser noise suppression, echo cancellation, and auto gain control',
|
|
93
93
|
'contextGlossary':'Context glossary injection',
|
|
@@ -113,26 +113,26 @@ const en = {
|
|
|
113
113
|
'updatePrompt':'A new version is available on npm. Click update to install.', 'updateNow':'Update now', 'updating':'Updating…',
|
|
114
114
|
'updateSuccess':'Updated successfully! Restart DSH to apply.', 'updateFailed':'Update failed. Check logs.',
|
|
115
115
|
'updateCheckFailed':'Update check failed',
|
|
116
|
-
'profileLockedPid':'Profile
|
|
117
|
-
'profileLockedExisting':'Profile
|
|
118
|
-
'profileLockCheckError':'Profile lock check failed. Filesystem inspection required
|
|
116
|
+
'profileLockedPid':'Profile locked by PID {pid}. Check operator recovery procedure.',
|
|
117
|
+
'profileLockedExisting':'Profile locked by lockfile. Check operator recovery procedure.',
|
|
118
|
+
'profileLockCheckError':'Profile lock check failed. Filesystem inspection required.',
|
|
119
119
|
'checkingUpdates':'Checking updates…', 'updateStatusUnknown':'Version status unknown',
|
|
120
120
|
'sensevoiceTitle':'SenseVoice Local ASR (1-Click Setup)',
|
|
121
|
-
'sensevoiceDesc':'Ultra-fast offline speech recognition on CPU (50–100ms latency
|
|
121
|
+
'sensevoiceDesc':'Ultra-fast offline speech recognition on CPU (50–100ms latency).',
|
|
122
122
|
'installSensevoice':'Install SenseVoice-Small (1-Click)', 'installingSensevoice':'Installing SenseVoice…', 'sensevoiceReady':'Ready',
|
|
123
123
|
'sensevoiceNotInstalled':'Not Installed', 'sensevoiceDownloading':'Downloading model…',
|
|
124
124
|
'turnTakingTitle':'Turn-Taking & Audio Coordination',
|
|
125
|
-
'turnTakingDesc':'
|
|
125
|
+
'turnTakingDesc':'Coordinates audio so assistant voice does not feed back into the microphone.',
|
|
126
126
|
'gatedTurnTaking':'Gated Mode (mute mic while assistant is speaking)',
|
|
127
|
-
'bargeInDesc':'True Barge-In (speaking interrupts assistant speech)', 'smartActionsTitle':'Hands-free & Smart Actions',
|
|
127
|
+
'bargeInDesc':'True Barge-In (speaking interrupts assistant speech)', 'smartActionsTitle':'Hands-free & Smart Actions', 'audioFeedback':'Audio cues',
|
|
128
128
|
'autoSendVisualRing':'Silence Ring countdown animation',
|
|
129
129
|
'voiceActionsLabel':'Voice action commands ("send", "cancel", "clear", "new line")',
|
|
130
130
|
'liveInterimPreview':'Live speech preview (ghost text preview)',
|
|
131
131
|
'structuredPromptVoice':'Spoken answers for interactive choice prompts', 'modeVerbatim':'Verbatim', 'modeClean':'Clean Text',
|
|
132
|
-
'modeTask':'Agent Task', 'modeNote':'Note', 'dictationModeTitle':'Dictation Post-Processing Mode',
|
|
133
|
-
'dictationModeDesc':'
|
|
132
|
+
'modeTask':'Agent Task', 'modeNote':'Note', 'modeBug':'Bug Report', 'promptBug':'Bug report prompt', 'promptBugPlaceholder':'Default: problem summary, symptoms, repro steps, expected behavior', 'dictationModeTitle':'Dictation Post-Processing Mode',
|
|
133
|
+
'dictationModeDesc':'Dictation post-processing: Verbatim (no LLM), Clean (punct & fillers), Agent task, or Note.',
|
|
134
134
|
'dictationPromptsTitle':'Dictation Prompt Templates',
|
|
135
|
-
'dictationPromptsDesc':'Custom
|
|
135
|
+
'dictationPromptsDesc':'Custom templates for dictation modes. Use {text} as speech placeholder.',
|
|
136
136
|
'promptClean':'Clean text prompt', 'promptTask':'Agent task prompt', 'promptNote':'Note prompt', 'resetPrompts':'Reset to defaults',
|
|
137
137
|
'voiceMacrosTitle':'Voice Action Macros',
|
|
138
138
|
'voiceMacrosDesc':'Spoken trigger phrases automatically expanded into structured prompt templates.', 'addMacro':'Add macro',
|
|
@@ -142,7 +142,7 @@ const en = {
|
|
|
142
142
|
'jargonFrom':'Spoken slang', 'jargonTo':'Correct spelling', 'jargonPlaceholder':'k8s -> kubernetes\npr -> pull request',
|
|
143
143
|
'voiceInput':'Voice input', 'assistantSpeakingGated':'Assistant speaking (gated mode)', 'jargonFormatHint':' (spoken -> replacement)',
|
|
144
144
|
'errorPrefix':'Error', 'wizardTitle':'First-Run Setup & Diagnostics Wizard',
|
|
145
|
-
'wizardDesc':'
|
|
145
|
+
'wizardDesc':'Diagnostics: check HTTPS/context, microphone access, audio level, and STT round-trip.',
|
|
146
146
|
'wizardBtnLaunch':'Launch Mic & STT Wizard', 'wizardClose':'Close Wizard', 'wizardStep1':'1. Audio & Environment',
|
|
147
147
|
'wizardStep2':'2. Live Signal Test', 'wizardStep3':'3. STT Transcription Test',
|
|
148
148
|
'wizardSecureContextOk':'Secure context / HTTPS verified', 'wizardSecureContextBad':'Insecure context (HTTPS or localhost required)',
|
|
@@ -158,39 +158,39 @@ const en = {
|
|
|
158
158
|
'wizardAreaServer':'Local MiniPC server (SenseVoice / Whisper)', 'wizardAreaCloud':'Remote cloud provider',
|
|
159
159
|
'wizardStartTestRecord':'Record 3-Second Test Phrase', 'wizardRecordingTest':'Recording test phrase… speak now ({left}s)',
|
|
160
160
|
'wizardTranscribingTest':'Transcribing test phrase…', 'wizardTestResult':'STT Test Result:',
|
|
161
|
-
'wizardTestSuccess':'STT
|
|
162
|
-
'wizardTestEmpty':'No speech detected
|
|
161
|
+
'wizardTestSuccess':'STT verified! Latency: {latency}ms',
|
|
162
|
+
'wizardTestEmpty':'No speech detected. Please speak clearly and retry.',
|
|
163
163
|
'wizardTestFailed':'STT test failed: {error}', 'wizardNextStepHint':'Next step: {hint}',
|
|
164
164
|
'wizardHintPermission':'Click "Request Microphone Access" and allow browser permission prompt.',
|
|
165
165
|
'wizardHintDevice':'Check microphone connection or select a different input device.',
|
|
166
166
|
'wizardHintHttps':'Open DeepSeek Harness via HTTPS or localhost address.',
|
|
167
167
|
'wizardHintProvider':'Configure STT engine credentials or install SenseVoice model below.',
|
|
168
|
-
'wizardHintWinDesktop':'
|
|
169
|
-
'wizardHintWinBrowser':'
|
|
170
|
-
'wizardHintMacDesktop':'
|
|
168
|
+
'wizardHintWinDesktop':'Windows Settings → Privacy → Microphone, enable desktop access.',
|
|
169
|
+
'wizardHintWinBrowser':'Allow microphone access in browser address bar.',
|
|
170
|
+
'wizardHintMacDesktop':'macOS Settings → Privacy → Microphone, enable DSH.',
|
|
171
171
|
'wizardOpenWinMicSettings':'Open Windows Mic Settings', 'wizardFinishSuccess':'Setup & Verification Complete',
|
|
172
|
-
'wizardSkip':'Skip Wizard', 'wizardStatusCompleted':'
|
|
172
|
+
'wizardSkip':'Skip Wizard', 'wizardStatusCompleted':'Mic & STT verified', 'exportDiagnosticsBtn':'Export Diagnostics',
|
|
173
173
|
'exportingDiagnostics':'Exporting report…', 'diagnosticsExportSuccess':'Report downloaded',
|
|
174
|
-
'recentRecognitionsTitle':'Recent
|
|
174
|
+
'recentRecognitionsTitle':'Recent Recognitions', 'noRecognitionsYet':'No recent recognition records yet.',
|
|
175
175
|
'diagLatencyBreakdown':'Latency breakdown:', 'diagVad':'VAD: {ms}ms', 'diagStt':'STT: {ms}ms', 'diagPolish':'Polish: {ms}ms',
|
|
176
176
|
'diagTotal':'Total: {ms}ms', 'diagBytes':'Audio: {bytes} B', 'diagWords':'Words: {count}',
|
|
177
|
-
'diagExportNotice':'Exported JSON contains anonymized timings
|
|
177
|
+
'diagExportNotice':'Exported JSON contains anonymized timings and error codes.',
|
|
178
178
|
'hostOnline':'Host online', 'hostOffline':'Host unreachable', 'whisperReady':'Whisper ready', 'whisperStopped':'Whisper stopped',
|
|
179
179
|
'providersAvailable':'providers available', 'macroEmpty':'No macros configured.', 'macroTemplateArgHint':' (use {text} for argument)',
|
|
180
|
-
'noiseGateLow':'-50 dB (Low
|
|
181
|
-
'noiseGateHigh':'-25 dB (High
|
|
182
|
-
'installModelSensevoice':'SenseVoice-Small (150MB
|
|
183
|
-
'promptCleanPlaceholder':'
|
|
184
|
-
'promptTaskPlaceholder':'
|
|
185
|
-
'promptNotePlaceholder':'
|
|
180
|
+
'noiseGateLow':'-50 dB (Low)', 'noiseGateStandard':'-45 dB (Default)', 'noiseGateMedium':'-35 dB (Medium)',
|
|
181
|
+
'noiseGateHigh':'-25 dB (High)', 'npuCpu':'CPU (Standard)',
|
|
182
|
+
'installModelSensevoice':'SenseVoice-Small (150MB)', 'installModelWhisperTurbo':'Whisper Large-v3-Turbo (800MB)',
|
|
183
|
+
'promptCleanPlaceholder':'Punctuation & filler cleanup',
|
|
184
|
+
'promptTaskPlaceholder':'Structured task format',
|
|
185
|
+
'promptNotePlaceholder':'Key points & action items', 'settingsConflict':'Settings conflict: parallel changes detected',
|
|
186
186
|
'saveFailedFallback':'Save failed', 'benchmarkFailed':'Benchmark failed', 'networkError':'Network error', 'benchmarkOffline':'Offline',
|
|
187
187
|
'benchmarkCores':'Cores', 'benchmarkCoresUnit':'cores', 'benchRatingUltraFast':'Ultra-fast', 'benchRatingRealtime':'Real-time',
|
|
188
|
-
'msShort':'ms', 'transcriptionTimeout':'Transcription
|
|
188
|
+
'msShort':'ms', 'transcriptionTimeout':'Transcription timed out', 'audioContextUnsupported':'AudioContext not supported',
|
|
189
189
|
'audioReadFailed':'failed to read audio', 'fileReaderUnsupported':'FileReader not supported',
|
|
190
|
-
'benchmarkNoAsrServer':'Local ASR
|
|
190
|
+
'benchmarkNoAsrServer':'Local ASR offline. Hardware detected.',
|
|
191
191
|
}
|
|
192
192
|
const zh = {
|
|
193
|
-
'saveFailed':'部分字段未保存 —', 'cardHint':'
|
|
193
|
+
'saveFailed':'部分字段未保存 —', 'cardHint':'听写与语音输入设置', 'expand':'展开', 'collapse':'收起', 'composerUnavailable':'输入框不可用',
|
|
194
194
|
'keySpace':'空格', 'keyUnset':'未设置', 'recognitionError':'识别失败', 'micUnavailable':'麦克风不可用:需要 HTTPS 或 localhost',
|
|
195
195
|
'noRecorder':'当前浏览器不支持 MediaRecorder', 'browserFailed':'浏览器未能识别:', 'nothingHeard':'未识别到任何内容', 'dictationBtn':'语音输入',
|
|
196
196
|
'messageBtn':'语音消息 — 点击或按住', 'dictationPill':'听写 — 文本将追加至输入框', 'messagePill':'正在录制语音消息', 'cancel':'取消', 'holdHint':'按住录音 — 松开即发送',
|
|
@@ -255,10 +255,10 @@ const zh = {
|
|
|
255
255
|
'sensevoiceDesc':'CPU 上超低延迟离线语音识别 (50–100ms,中英俄多语种)。', 'installSensevoice':'一键安装 SenseVoice-Small',
|
|
256
256
|
'installingSensevoice':'正在安装 SenseVoice…', 'sensevoiceReady':'已就绪', 'sensevoiceNotInstalled':'未安装', 'sensevoiceDownloading':'正在下载模型…',
|
|
257
257
|
'turnTakingTitle':'轮流对话与音频协同', 'turnTakingDesc':'协调听与说,避免扬声器播放的声音被麦克风二次拾音。', 'gatedTurnTaking':'门控模式 (助手播报时麦克风自动静音)',
|
|
258
|
-
'bargeInDesc':'实时打断 (说话时立即打断助手朗读)', 'smartActionsTitle':'免提与智能指令', 'autoSendVisualRing':'环形倒计时动画指示器',
|
|
258
|
+
'bargeInDesc':'实时打断 (说话时立即打断助手朗读)', 'smartActionsTitle':'免提与智能指令', 'audioFeedback':'声音提示', 'autoSendVisualRing':'环形倒计时动画指示器',
|
|
259
259
|
'voiceActionsLabel':'语音动作指令 ("发送", "取消", "清空", "换行")', 'liveInterimPreview':'实时语音文本预览 (幽灵文本)', 'structuredPromptVoice':'语音应答交互式选择提示',
|
|
260
|
-
'modeVerbatim':'逐字直录', 'modeClean':'清爽文本', 'modeTask':'智能体任务', 'modeNote':'便签备忘', 'dictationModeTitle':'听写后处理模式',
|
|
261
|
-
'dictationModeDesc':'
|
|
260
|
+
'modeVerbatim':'逐字直录', 'modeClean':'清爽文本', 'modeTask':'智能体任务', 'modeNote':'便签备忘', 'modeBug':'缺陷报告', 'promptBug':'缺陷报告提示词', 'promptBugPlaceholder':'默认:问题概要、异常现象、复现步骤、预期行为', 'dictationModeTitle':'听写后处理模式',
|
|
261
|
+
'dictationModeDesc':'听写文本后处理:逐字直录(零LLM)、清爽文本、智能体任务或便签。', 'dictationPromptsTitle':'听写提示词模板',
|
|
262
262
|
'dictationPromptsDesc':'自定义听写后处理提示词模板。使用 {text} 作为识别语音的占位符。', 'promptClean':'清爽文本提示词', 'promptTask':'智能体任务提示词', 'promptNote':'便签提示词',
|
|
263
263
|
'resetPrompts':'恢复默认模板', 'voiceMacrosTitle':'语音动作宏', 'voiceMacrosDesc':'语音触发词自动展开为结构化提示词模板。', 'addMacro':'添加动作宏',
|
|
264
264
|
'macroTrigger':'语音触发短语', 'macroTemplate':'展开提示词模板', 'macroDelete':'删除', 'rawTab':'原始识别', 'resultTab':'处理结果',
|
|
@@ -283,7 +283,7 @@ const zh = {
|
|
|
283
283
|
'wizardHintWinDesktop':'系统麦克风被阻止。请在 Windows【设置】→【隐私和安全性】→【麦克风】中开启最下方的【允许桌面应用访问你的麦克风】。',
|
|
284
284
|
'wizardHintWinBrowser':'麦克风权限被拒绝。请在浏览器地址栏允许麦克风权限,或在 Windows【设置】→【隐私和安全性】→【麦克风】中开启访问。',
|
|
285
285
|
'wizardHintMacDesktop':'系统麦克风被阻止。请在 macOS【系统设置】→【隐私与安全性】→【麦克风】中勾选允许 DSH Desktop。', 'wizardOpenWinMicSettings':'打开系统麦克风设置',
|
|
286
|
-
'wizardFinishSuccess':'设置与验证已完成', 'wizardSkip':'跳过向导', 'wizardStatusCompleted':'麦克风与 STT 诊断已就绪', 'exportDiagnosticsBtn':'
|
|
286
|
+
'wizardFinishSuccess':'设置与验证已完成', 'wizardSkip':'跳过向导', 'wizardStatusCompleted':'麦克风与 STT 诊断已就绪', 'exportDiagnosticsBtn':'导出诊断',
|
|
287
287
|
'exportingDiagnostics':'正在导出报告…', 'diagnosticsExportSuccess':'诊断报告已下载', 'recentRecognitionsTitle':'近期识别遥测详情',
|
|
288
288
|
'noRecognitionsYet':'暂无近期识别记录。', 'diagLatencyBreakdown':'耗时分布:', 'diagVad':'VAD:{ms}毫秒', 'diagStt':'STT:{ms}毫秒',
|
|
289
289
|
'diagPolish':'后处理:{ms}毫秒', 'diagTotal':'总耗时:{ms}毫秒', 'diagBytes':'音频大小:{bytes} 字节', 'diagWords':'词数:{count}',
|
|
@@ -301,7 +301,7 @@ const zh = {
|
|
|
301
301
|
let moduleT = (key) => en[key] || key
|
|
302
302
|
const t = (key) => moduleT(key)
|
|
303
303
|
const CSS =
|
|
304
|
-
'.dvo-btn{display:flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:50%;border:1px solid var(--dsw-alias-border-l1);background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;padding:0;box-sizing:border-box;user-select:none;-webkit-user-select:none;touch-action:manipulation}.dvo-btn:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}.dvo-btn[data-err="1"]{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}.dvo-pill{display:flex;align-items:center;gap:10px;height:52px;border-radius:26px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);padding:0 14px;width:100%;max-width:720px;margin:0 auto;box-shadow:0 8px 24px color-mix(in srgb, var(--dsw-alias-label-primary) 18%, transparent);box-sizing:border-box;user-select:none;-webkit-user-select:none}.dvo-chev-icon{width:14px;height:14px;display:block;flex:none}.dvo-pbtn{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:50%;cursor:pointer;padding:0;flex:none;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);user-select:none;-webkit-user-select:none;touch-action:manipulation}.dvo-pbtn:hover{background:var(--dsw-alias-bg-layer-2)}.dvo-wave{flex:1;min-width:0;max-width:100%;height:40px;width:100%;color:var(--dsw-alias-label-primary)}.dvo-status{display:flex;align-items:center;gap:8px;color:var(--dsw-alias-label-secondary);font-size:13px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dvo-err{color:var(--dsw-alias-state-error-primary)}.dvo-count{font-variant-numeric:tabular-nums;font-size:13px;color:var(--dsw-alias-label-secondary)}.dvo-spin{animation:dvo-spin 1s linear infinite}@keyframes dvo-spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}.dvo-btn-active{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2)}.dvo-audio-wrap{display:flex;align-items:center;gap:8px;padding:2px 10px;background:var(--dsw-alias-bg-layer-2);border-radius:14px;border:1px solid var(--dsw-alias-border-l1)}.dvo-audio-play{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-1);border:0;cursor:pointer;padding:0}.dvo-audio-play:hover{opacity:0.9}.dvo-audio-time{font-size:12px;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary)}.dvo-dash{display:flex;flex-direction:column;gap:8px;margin-top:8px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:12px}.dvo-dash-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px;margin-top:4px}.dvo-dash-item{display:flex;flex-direction:column;gap:4px;padding:8px 10px;background:var(--dsw-alias-bg-layer-3);border:1px solid var(--dsw-alias-border-l1);border-radius:8px}.dvo-dash-name{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary)}.dvo-dash-row{display:flex;justify-content:space-between;align-items:center;font-size:11px;color:var(--dsw-alias-label-secondary)}.dvo-badge{display:inline-flex;align-items:center;font-size:11px;padding:1px 6px;border-radius:6px;font-weight:600}.dvo-badge-fast{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-state-success-primary);border:1px solid var(--dsw-alias-state-success-primary)}.dvo-badge-norm{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-state-warning-primary);border:1px solid var(--dsw-alias-state-warning-primary)}.dvo-badge-slow{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-state-warning-primary);border:1px solid var(--dsw-alias-border-l2)}.dvo-badge-err{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-state-error-primary);border:1px solid var(--dsw-alias-state-error-primary)}.dvo-badge-idle{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-tertiary)}.dvo-mic-test{display:flex;align-items:center;gap:10px;margin-top:8px;padding:6px 12px;background:var(--dsw-alias-bg-layer-2);border-radius:8px;border:1px solid var(--dsw-alias-border-l1)}.dvo-meter-bar{flex:1;height:8px;background:var(--dsw-alias-bg-layer-3);border-radius:4px;overflow:hidden;position:relative}.dvo-meter-fill{height:100%;background:var(--dsw-alias-state-success-primary);border-radius:4px;transition:width 60ms ease-out}.dvo-meter-gate{position:absolute;top:0;bottom:0;width:2px;background:var(--dsw-alias-state-warning-primary);box-shadow:0 0 4px var(--dsw-alias-state-warning-primary);z-index:2;pointer-events:none}.dvo-silence-ring{width:34px;height:34px;transform:rotate(-90deg);flex:none}.dvo-ring-bg{fill:none;stroke:var(--dsw-alias-border-l1);stroke-width:2.5}.dvo-ring-fg{fill:none;stroke:var(--dsw-alias-state-info-primary);stroke-width:2.5;stroke-linecap:round;transition:stroke-dashoffset 100ms linear}.dvo-ghost{font-style:italic;color:var(--dsw-alias-label-tertiary);margin-left:6px;max-width:240px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}.dvo-installer-box{display:flex;flex-direction:column;gap:8px;padding:10px 12px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;margin-top:8px}.dvo-installer-row{display:flex;align-items:center;justify-content:space-between;gap:8px}.dvo-progress-bar{height:6px;width:100%;background:var(--dsw-alias-bg-layer-3);border-radius:3px;overflow:hidden}.dvo-progress-fill{height:100%;background:var(--dsw-alias-state-info-primary);transition:width 150ms ease}.dvo-jargon-table{width:100%;margin-top:6px;border-collapse:collapse;font-size:12px}.dvo-jargon-table td{padding:4px 6px;border-bottom:1px solid var(--dsw-alias-border-l1)}.dvo-pill-preview{display:flex;flex-direction:column;gap:8px;padding:10px 14px;border-radius:18px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);width:100%;max-width:720px;margin:0 auto;box-shadow:0 8px 24px color-mix(in srgb, var(--dsw-alias-label-primary) 18%, transparent);box-sizing:border-box}.dvo-preview-header{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%}.dvo-preview-tabs{display:inline-flex;align-items:center;gap:4px;background:var(--dsw-alias-bg-layer-2);padding:2px;border-radius:12px;border:1px solid var(--dsw-alias-border-l1)}.dvo-tab-btn{border:none;background:transparent;color:var(--dsw-alias-label-secondary);font-size:11px;font-weight:500;padding:3px 10px;border-radius:10px;cursor:pointer;transition:all 150ms ease}.dvo-tab-btn:hover{color:var(--dsw-alias-label-primary)}.dvo-tab-btn-active{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);box-shadow:0 1px 3px color-mix(in srgb, var(--dsw-alias-label-primary) 15%, transparent)}.dvo-preview-body{display:flex;align-items:center;gap:8px;width:100%}.dvo-preview-text{flex:1;font-size:13px;color:var(--dsw-alias-label-primary);line-height:1.4;word-break:break-word;max-height:80px;overflow-y:auto;padding:2px 0}.dvo-preview-input{flex:1;font-size:13px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:6px 8px;outline:none;font-family:inherit;width:100%}.dvo-preview-input:focus{border-color:var(--dsw-alias-state-info-primary)}.dvo-btn-send{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:50%;cursor:pointer;padding:0;flex:none;box-sizing:border-box;border:none;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-1);transition:opacity 150ms ease}.dvo-btn-send:hover{opacity:0.9}.dvo-warn-banner{font-size:12px;color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 12%, transparent);border:1px solid var(--dsw-alias-state-error-primary);padding:4px 8px;border-radius:6px;margin-top:4px}' + '.dvo-mode-pill-btn{display:inline-flex;align-items:center;justify-content:center;height:28px;padding:0 8px;font-size:11px;font-weight:600;border-radius:14px;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);user-select:none;touch-action:manipulation;transition:all 150ms ease}' + '.dvo-mode-pill-btn:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary)}' + '.dvo-mode-badge{font-size:11px;font-weight:600;padding:2px 6px;border-radius:6px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);margin-right:4px}' + '.dvo-macro-item{display:flex;flex-direction:column;gap:6px;padding:8px 10px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;margin-top:6px}' + '.dvo-macro-actions{display:flex;justify-content:flex-end;gap:6px}' + '.dvo-fallback-badge{font-size:11px;padding:2px 6px;border-radius:4px;color:var(--dsw-alias-state-warning-primary);background:color-mix(in srgb, var(--dsw-alias-state-warning-primary) 12%, transparent);border:1px solid var(--dsw-alias-state-warning-primary)}.dvo-wave-clipping{color:var(--dsw-alias-state-warning-primary)!important;}.dvo-wave-low{color:var(--dsw-alias-label-secondary)!important;}.dvo-quality-badge{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500;display:inline-flex;align-items:center;gap:3px;}.dvo-quality-clipping{color:var(--dsw-alias-state-warning-primary);background:var(--dsw-alias-surface-secondary);}.dvo-quality-low{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-surface-secondary);}.dvo-undo-badge{font-size:11px;padding:2px 6px;border-radius:4px;background:var(--dsw-alias-surface-secondary);color:var(--dsw-alias-label-primary);display:inline-flex;align-items:center;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}'
|
|
304
|
+
'.dvo-btn{display:flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:50%;border:1px solid var(--dsw-alias-border-l1);background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;padding:0;user-select:none;touch-action:manipulation}.dvo-btn:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}.dvo-btn[data-err="1"]{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}.dvo-pill{display:flex;align-items:center;gap:10px;height:52px;border-radius:26px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);padding:0 14px;width:100%;max-width:720px;margin:0 auto;box-shadow:0 8px 24px color-mix(in srgb, var(--dsw-alias-label-primary) 18%, transparent);user-select:none;-webkit-user-select:none}.dvo-chev-icon{width:14px;height:14px;display:block;flex:none}.dvo-pbtn{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:50%;cursor:pointer;padding:0;flex:none;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);user-select:none;touch-action:manipulation}.dvo-pbtn:hover{background:var(--dsw-alias-bg-layer-2)}.dvo-wave{flex:1;min-width:0;max-width:100%;height:40px;width:100%;color:var(--dsw-alias-label-primary)}.dvo-status{display:flex;align-items:center;gap:8px;color:var(--dsw-alias-label-secondary);font-size:13px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dvo-err{color:var(--dsw-alias-state-error-primary)}.dvo-count{font-variant-numeric:tabular-nums;font-size:13px;color:var(--dsw-alias-label-secondary)}.dvo-spin{animation:dvo-spin 1s linear infinite}@keyframes dvo-spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}.dvo-btn-active{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2)}.dvo-audio-wrap{display:flex;align-items:center;gap:8px;padding:2px 10px;background:var(--dsw-alias-bg-layer-2);border-radius:14px;border:1px solid var(--dsw-alias-border-l1)}.dvo-audio-play{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-1);border:0;cursor:pointer;padding:0}.dvo-audio-play:hover{opacity:0.9}.dvo-audio-time{font-size:12px;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary)}.dvo-dash{display:flex;flex-direction:column;gap:8px;margin-top:8px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:12px}.dvo-dash-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px;margin-top:4px}.dvo-dash-item{display:flex;flex-direction:column;gap:4px;padding:8px 10px;background:var(--dsw-alias-bg-layer-3);border:1px solid var(--dsw-alias-border-l1);border-radius:8px}.dvo-dash-name{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary)}.dvo-dash-row{display:flex;justify-content:space-between;align-items:center;font-size:11px;color:var(--dsw-alias-label-secondary)}.dvo-badge{display:inline-flex;align-items:center;font-size:11px;padding:1px 6px;border-radius:6px;font-weight:600}.dvo-badge-fast{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-state-success-primary);border:1px solid var(--dsw-alias-state-success-primary)}.dvo-badge-norm{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-state-warning-primary);border:1px solid var(--dsw-alias-state-warning-primary)}.dvo-badge-slow{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-state-warning-primary);border:1px solid var(--dsw-alias-border-l2)}.dvo-badge-err{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-state-error-primary);border:1px solid var(--dsw-alias-state-error-primary)}.dvo-badge-idle{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-tertiary)}.dvo-mic-test{display:flex;align-items:center;gap:10px;margin-top:8px;padding:6px 12px;background:var(--dsw-alias-bg-layer-2);border-radius:8px;border:1px solid var(--dsw-alias-border-l1)}.dvo-meter-bar{flex:1;height:8px;background:var(--dsw-alias-bg-layer-3);border-radius:4px;overflow:hidden;position:relative}.dvo-meter-fill{height:100%;background:var(--dsw-alias-state-success-primary);border-radius:4px;transition:width 60ms ease-out}.dvo-meter-gate{position:absolute;top:0;bottom:0;width:2px;background:var(--dsw-alias-state-warning-primary);box-shadow:0 0 4px var(--dsw-alias-state-warning-primary);z-index:2;pointer-events:none}.dvo-silence-ring{width:34px;height:34px;transform:rotate(-90deg);flex:none}.dvo-ring-bg{fill:none;stroke:var(--dsw-alias-border-l1);stroke-width:2.5}.dvo-ring-fg{fill:none;stroke:var(--dsw-alias-state-info-primary);stroke-width:2.5;stroke-linecap:round;transition:stroke-dashoffset 100ms linear}.dvo-ghost{font-style:italic;color:var(--dsw-alias-label-tertiary);margin-left:6px;max-width:240px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}.dvo-installer-box{display:flex;flex-direction:column;gap:8px;padding:10px 12px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;margin-top:8px}.dvo-installer-row{display:flex;align-items:center;justify-content:space-between;gap:8px}.dvo-progress-bar{height:6px;width:100%;background:var(--dsw-alias-bg-layer-3);border-radius:3px;overflow:hidden}.dvo-progress-fill{height:100%;background:var(--dsw-alias-state-info-primary);transition:width 150ms ease}.dvo-jargon-table{width:100%;margin-top:6px;border-collapse:collapse;font-size:12px}.dvo-jargon-table td{padding:4px 6px;border-bottom:1px solid var(--dsw-alias-border-l1)}.dvo-pill-preview{display:flex;flex-direction:column;gap:8px;padding:10px 14px;border-radius:18px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);width:100%;max-width:720px;margin:0 auto;box-shadow:0 8px 24px color-mix(in srgb, var(--dsw-alias-label-primary) 18%, transparent);box-sizing:border-box}.dvo-preview-header{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%}.dvo-preview-tabs{display:inline-flex;align-items:center;gap:4px;background:var(--dsw-alias-bg-layer-2);padding:2px;border-radius:12px;border:1px solid var(--dsw-alias-border-l1)}.dvo-tab-btn{border:none;background:transparent;color:var(--dsw-alias-label-secondary);font-size:11px;font-weight:500;padding:3px 10px;border-radius:10px;cursor:pointer;transition:all 150ms ease}.dvo-tab-btn:hover{color:var(--dsw-alias-label-primary)}.dvo-tab-btn-active{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);box-shadow:0 1px 3px color-mix(in srgb, var(--dsw-alias-label-primary) 15%, transparent)}.dvo-preview-body{display:flex;align-items:center;gap:8px;width:100%}.dvo-preview-text{flex:1;font-size:13px;color:var(--dsw-alias-label-primary);line-height:1.4;word-break:break-word;max-height:80px;overflow-y:auto;padding:2px 0}.dvo-preview-input{flex:1;font-size:13px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:6px 8px;outline:none;font-family:inherit;width:100%}.dvo-preview-input:focus{border-color:var(--dsw-alias-state-info-primary)}.dvo-btn-send{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:50%;cursor:pointer;padding:0;flex:none;border:none;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-1);transition:opacity 150ms ease}.dvo-btn-send:hover{opacity:0.9}.dvo-warn-banner{font-size:12px;color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 12%, transparent);border:1px solid var(--dsw-alias-state-error-primary);padding:4px 8px;border-radius:6px;margin-top:4px}.dvo-mode-pill-btn{display:inline-flex;align-items:center;justify-content:center;height:28px;padding:0 8px;font-size:11px;font-weight:600;border-radius:14px;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);user-select:none;transition:all 150ms ease}.dvo-mode-pill-btn:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary)}.dvo-mode-badge{font-size:11px;font-weight:600;padding:2px 6px;border-radius:6px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);margin-right:4px}.dvo-macro-item{display:flex;flex-direction:column;gap:6px;padding:8px 10px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;margin-top:6px}.dvo-macro-actions{display:flex;justify-content:flex-end;gap:6px}.dvo-fallback-badge{font-size:11px;padding:2px 6px;border-radius:4px;color:var(--dsw-alias-state-warning-primary);background:color-mix(in srgb, var(--dsw-alias-state-warning-primary) 12%, transparent);border:1px solid var(--dsw-alias-state-warning-primary)}.dvo-wave-clipping{color:var(--dsw-alias-state-warning-primary)!important;}.dvo-wave-low{color:var(--dsw-alias-label-secondary)!important;}.dvo-quality-badge{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500;display:inline-flex;align-items:center;gap:3px;}.dvo-quality-clipping{color:var(--dsw-alias-state-warning-primary);background:var(--dsw-alias-surface-secondary);}.dvo-quality-low{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-surface-secondary);}.dvo-undo-badge{font-size:11px;padding:2px 6px;border-radius:4px;background:var(--dsw-alias-surface-secondary);color:var(--dsw-alias-label-primary);display:inline-flex;align-items:center;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}'
|
|
305
305
|
const cssId = 'dsh-voice/client.module.css'
|
|
306
306
|
if (typeof document !== 'undefined' && !document.querySelector('style[data-dsh-plugin="dsh-voice"][data-plugin-css="' + cssId + '"]')) {const tag = document.createElement('style')
|
|
307
307
|
tag.textContent = CSS
|
|
@@ -345,6 +345,70 @@ md: '13px',
|
|
|
345
345
|
lg: '15px',
|
|
346
346
|
},
|
|
347
347
|
}
|
|
348
|
+
let _ac = null
|
|
349
|
+
function playAudioCue(t, { enabled = true } = {}) {
|
|
350
|
+
if (!enabled || typeof window === 'undefined') return
|
|
351
|
+
try {
|
|
352
|
+
const C = window.AudioContext || window.webkitAudioContext
|
|
353
|
+
if (!C) return
|
|
354
|
+
if (!_ac || _ac.state === 'closed') _ac = new C()
|
|
355
|
+
if (_ac.state === 'suspended') _ac.resume().catch(() => {})
|
|
356
|
+
const n = _ac.currentTime, o = _ac.createOscillator(), g = _ac.createGain()
|
|
357
|
+
o.connect(g); g.connect(_ac.destination)
|
|
358
|
+
if (t === 'start') {
|
|
359
|
+
o.frequency.setValueAtTime(440, n); o.frequency.exponentialRampToValueAtTime(880, n + 0.035)
|
|
360
|
+
g.gain.setValueAtTime(0.04, n); g.gain.exponentialRampToValueAtTime(0.001, n + 0.04)
|
|
361
|
+
o.start(n); o.stop(n + 0.045)
|
|
362
|
+
} else if (t === 'stop') {
|
|
363
|
+
o.frequency.setValueAtTime(700, n); o.frequency.exponentialRampToValueAtTime(350, n + 0.035)
|
|
364
|
+
g.gain.setValueAtTime(0.04, n); g.gain.exponentialRampToValueAtTime(0.001, n + 0.04)
|
|
365
|
+
o.start(n); o.stop(n + 0.045)
|
|
366
|
+
} else if (t === 'success') {
|
|
367
|
+
o.type = 'triangle'; o.frequency.setValueAtTime(587.33, n); o.frequency.setValueAtTime(880, n + 0.02)
|
|
368
|
+
g.gain.setValueAtTime(0.035, n); g.gain.exponentialRampToValueAtTime(0.001, n + 0.06)
|
|
369
|
+
o.start(n); o.stop(n + 0.065)
|
|
370
|
+
}
|
|
371
|
+
} catch (_) {}
|
|
372
|
+
}
|
|
373
|
+
const DEV_TRANSLIT = Object.fromEntries('а:a,б:b,в:v,г:g,д:d,е:e,ё:yo,ж:zh,з:z,и:i,й:y,к:k,л:l,м:m,н:n,о:o,п:p,р:r,с:s,т:t,у:u,ф:f,х:h,ц:ts,ч:ch,ш:sh,щ:sch,ъ:,ы:y,ь:,э:e,ю:yu,я:ya'.split(',').map((s) => s.split(':')))
|
|
374
|
+
const CLIENT_DEV_WORDS = Object.fromEntries('юзер:user,айди:id,нейм:name,дата:data,инфо:info,токен:token,конфиг:config,статус:status,счетчик:count,ошибка:error,ключ:key,сервис:service,клиент:client,хэндлер:handler'.split(',').map((s) => s.split(':')))
|
|
375
|
+
function transliterateDevWord(w) {
|
|
376
|
+
const low = String(w || '').toLowerCase()
|
|
377
|
+
return CLIENT_DEV_WORDS[low] || low.split('').map((c) => DEV_TRANSLIT[c] || c).join('')
|
|
378
|
+
}
|
|
379
|
+
function devWordsOf(str) {
|
|
380
|
+
return String(str || '').trim().split(/[\s_-]+/).filter(Boolean).map(transliterateDevWord)
|
|
381
|
+
}
|
|
382
|
+
const caseFn = {
|
|
383
|
+
c: (ws) => ws.length ? ws[0].toLowerCase() + ws.slice(1).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join('') : '',
|
|
384
|
+
p: (ws) => ws.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(''),
|
|
385
|
+
s: (ws) => ws.map((w) => w.toLowerCase()).join('_'),
|
|
386
|
+
u: (ws) => ws.map((w) => w.toUpperCase()).join('_'),
|
|
387
|
+
k: (ws) => ws.map((w) => w.toLowerCase()).join('-'),
|
|
388
|
+
}
|
|
389
|
+
function formatCasingClient(str, tc) {
|
|
390
|
+
const c = String(tc || '').toLowerCase()
|
|
391
|
+
const ws = devWordsOf(str)
|
|
392
|
+
const f = /camel|кэмел/.test(c) ? caseFn.c : /snake|снейк/.test(c) ? caseFn.s : /constant|констант|upper|апер/.test(c) ? caseFn.u : /kebab|кебаб/.test(c) ? caseFn.k : /pascal|паскаль/.test(c) ? caseFn.p : null
|
|
393
|
+
return f ? f(ws) : str
|
|
394
|
+
}
|
|
395
|
+
const CLIENT_CASING_TARGETS = '(?:(?:camel|кэмел|snake|снейк|constant|upper|kebab|кебаб|pascal|паскаль)[-_\\s]*(?:case|кейс|snake)?|констант(?:у|а)?|апер[-_\\s]*снейк)'
|
|
396
|
+
function applyCodeCasing(text) {
|
|
397
|
+
const kw = new RegExp('(^|[.,!?\\s])(?:переменн(?:ую|ая)|функци(?:ю|я)|метод|констант(?:у|а)|класс|компонент|тип|поле|var(?:iable)?|func(?:tion)?|method|const(?:ant)?|class|component)\\s+([a-zA-Zа-яА-ЯёЁ0-9_-]+(?:\\s+[a-zA-Zа-яА-ЯёЁ0-9_-]+){0,3})\\s+(?:в|to|in)\\s+(' + CLIENT_CASING_TARGETS + ')(?=[.,!?\\s]|$)', 'gi')
|
|
398
|
+
const sfx = new RegExp('(^|[.,!?\\s])([a-zA-Zа-яА-ЯёЁ0-9_-]+(?:\\s+[a-zA-Zа-яА-ЯёЁ0-9_-]+){0,2})\\s+(?:в|to|in)\\s+(' + CLIENT_CASING_TARGETS + ')(?=[.,!?\\s]|$)', 'gi')
|
|
399
|
+
return String(text || '')
|
|
400
|
+
.replace(kw, (_, lead, words, tc) => (lead || '') + formatCasingClient(words, tc))
|
|
401
|
+
.replace(sfx, (_, lead, words, tc) => (lead || '') + formatCasingClient(words, tc))
|
|
402
|
+
}
|
|
403
|
+
function cleanFillerWords(text) {
|
|
404
|
+
return String(text || '')
|
|
405
|
+
.replace(/(?<![a-zA-Zа-яА-ЯёЁ0-9])([a-zA-Zа-яА-ЯёЁ0-9]+)\s+\1(?![a-zA-Zа-яА-ЯёЁ0-9])/gi, '$1')
|
|
406
|
+
.replace(/(?<![a-zA-Zа-яА-ЯёЁ0-9])(?:ну\s+типа|как\s+бы|в\s+общем-то|так\s+сказать|короче\s+говоря|ээ+|мм+)(?![a-zA-Zа-яА-ЯёЁ0-9])/gi, '')
|
|
407
|
+
.replace(/(^|[.,!?\s])(?:ну|типа|короче|uh+|um+|you\s+know|basically|sort\s+of|kind\s+of)(?=[.,!?\s]|$)/gi, '$1')
|
|
408
|
+
.replace(/\s+/g, ' ')
|
|
409
|
+
.replace(/\s+([.,!?])/g, '$1')
|
|
410
|
+
.trim()
|
|
411
|
+
}
|
|
348
412
|
const apiClient = {
|
|
349
413
|
getTokenHeaders() {
|
|
350
414
|
return typeof window !== 'undefined' && window.__dshVoiceToken
|
|
@@ -578,9 +642,9 @@ window.dispatchEvent(new CustomEvent('dsh:tts:cancel', { bubbles: true }))
|
|
|
578
642
|
window.dispatchEvent(new CustomEvent('dsh:tts:stop', { bubbles: true }))
|
|
579
643
|
const audios = document.querySelectorAll('audio')
|
|
580
644
|
for (const a of audios) {
|
|
581
|
-
if (!a.paused) { try { a.pause() } catch (err) {
|
|
645
|
+
if (!a.paused) { try { a.pause() } catch (err) { } }
|
|
582
646
|
}
|
|
583
|
-
} catch {
|
|
647
|
+
} catch { }
|
|
584
648
|
voice.set({ isTtsSpeaking: false })
|
|
585
649
|
}
|
|
586
650
|
function findActiveStructuredPrompt() {
|
|
@@ -592,7 +656,7 @@ const input = modal.querySelector('textarea, input[type="text"]')
|
|
|
592
656
|
const buttons = Array.from(modal.querySelectorAll('button:not([disabled])'))
|
|
593
657
|
return { modal, input, buttons }
|
|
594
658
|
}
|
|
595
|
-
} catch {
|
|
659
|
+
} catch { }
|
|
596
660
|
return null
|
|
597
661
|
}
|
|
598
662
|
function submitToStructuredPrompt(text, promptInfo) {
|
|
@@ -680,12 +744,12 @@ function focusComposer() {
|
|
|
680
744
|
if (typeof window === 'undefined') return
|
|
681
745
|
const actions = voice.inputActions
|
|
682
746
|
if (actions && typeof actions.focus === 'function') {
|
|
683
|
-
try { actions.focus(); return } catch {
|
|
747
|
+
try { actions.focus(); return } catch { }
|
|
684
748
|
}
|
|
685
749
|
try {
|
|
686
750
|
const el = document.querySelector('.conversation-input textarea, .cb-composer textarea, .dsh-composer textarea, [data-slate-editor="true"], textarea')
|
|
687
751
|
if (el && typeof el.focus === 'function') el.focus()
|
|
688
|
-
} catch {
|
|
752
|
+
} catch { }
|
|
689
753
|
}
|
|
690
754
|
function blobToBase64(blob) {
|
|
691
755
|
return new Promise((resolve, reject) => {
|
|
@@ -710,6 +774,12 @@ if (t && t.length >= 3) chunks.push(t)
|
|
|
710
774
|
}
|
|
711
775
|
if (typeof document !== 'undefined') {
|
|
712
776
|
try {
|
|
777
|
+
if (document.title && document.title.length < 100) chunks.push(document.title)
|
|
778
|
+
const wsNodes = document.querySelectorAll('[data-filename], [data-path], .tab-active, .editor-tab-active, .dsh-breadcrumb')
|
|
779
|
+
for (let i = 0; i < Math.min(wsNodes.length, 6); i++) {
|
|
780
|
+
const val = wsNodes[i].getAttribute('data-filename') || wsNodes[i].getAttribute('data-path') || wsNodes[i].textContent
|
|
781
|
+
if (val && val.length < 80) chunks.push(val)
|
|
782
|
+
}
|
|
713
783
|
const nodes = document.querySelectorAll('.message-content code, .dsh-message-body code, pre code')
|
|
714
784
|
for (let i = 0; i < Math.min(nodes.length, 10); i++) {
|
|
715
785
|
const ct = nodes[i].textContent
|
|
@@ -773,7 +843,7 @@ throw e
|
|
|
773
843
|
if (timer) clearTimeout(timer)
|
|
774
844
|
}
|
|
775
845
|
let parsed = null
|
|
776
|
-
try { parsed = await res.json() } catch (e) {
|
|
846
|
+
try { parsed = await res.json() } catch (e) { }
|
|
777
847
|
if (!res.ok || !parsed || !parsed.ok) {
|
|
778
848
|
throw new Error((parsed && parsed.error && parsed.error.message) || `HTTP ${res.status}`)
|
|
779
849
|
}
|
|
@@ -830,6 +900,8 @@ const lead = (text.match(/^\n+/) || [''])[0]
|
|
|
830
900
|
const trail = (text.match(/\n+$/) || [''])[0]
|
|
831
901
|
let s = String(text).trim()
|
|
832
902
|
if (!s) return lead || trail || ''
|
|
903
|
+
if (typeof cleanFillerWords === 'function') s = cleanFillerWords(s)
|
|
904
|
+
if (typeof applyCodeCasing === 'function') s = applyCodeCasing(s)
|
|
833
905
|
s = s.replace(/\s*,\s*/g, ', ')
|
|
834
906
|
s = s.replace(/(^|[.!?\n]\s+)([a-zа-яё])/gi, (m, l, ch) => l + ch.toUpperCase())
|
|
835
907
|
return lead + s + trail
|
|
@@ -945,7 +1017,7 @@ return insertDraftText(clean, target)
|
|
|
945
1017
|
function announceVoice(phase) {
|
|
946
1018
|
try {
|
|
947
1019
|
window.dispatchEvent(new CustomEvent('dsh-voice:speaking', { detail: { phase } }))
|
|
948
|
-
} catch (noEvents) {
|
|
1020
|
+
} catch (noEvents) { }
|
|
949
1021
|
if (voice.settings.beep) playBeep(phase === 'start' ? 880 : 660)
|
|
950
1022
|
}
|
|
951
1023
|
function playBeep(freq) {
|
|
@@ -962,8 +1034,8 @@ gain.gain.setValueAtTime(0.12, ac.currentTime)
|
|
|
962
1034
|
gain.gain.exponentialRampToValueAtTime(0.001, ac.currentTime + 0.09)
|
|
963
1035
|
osc.connect(gain); gain.connect(ac.destination)
|
|
964
1036
|
osc.start(); osc.stop(ac.currentTime + 0.1)
|
|
965
|
-
osc.onended = () => { try { ac.close() } catch (e) {
|
|
966
|
-
} catch (noAudio) {
|
|
1037
|
+
osc.onended = () => { try { ac.close() } catch (e) { } }
|
|
1038
|
+
} catch (noAudio) { }
|
|
967
1039
|
}
|
|
968
1040
|
function speechRecognitionCtor() {
|
|
969
1041
|
if (typeof window === 'undefined') return null
|
|
@@ -986,10 +1058,6 @@ return navigator.language
|
|
|
986
1058
|
}
|
|
987
1059
|
return 'en-US'
|
|
988
1060
|
}
|
|
989
|
-
/**
|
|
990
|
-
* @param options {{lang: string, continuous: boolean, onInterim, onFinal, onError}}
|
|
991
|
-
* @returns {{stop: Function, abort: Function}}
|
|
992
|
-
*/
|
|
993
1061
|
function startBrowserRecognition(options) {
|
|
994
1062
|
const Ctor = speechRecognitionCtor()
|
|
995
1063
|
const recognition = new Ctor()
|
|
@@ -1023,7 +1091,7 @@ if (stopped) {
|
|
|
1023
1091
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1024
1092
|
return
|
|
1025
1093
|
}
|
|
1026
|
-
try { recognition.start() } catch (alreadyRunning) {
|
|
1094
|
+
try { recognition.start() } catch (alreadyRunning) { }
|
|
1027
1095
|
}
|
|
1028
1096
|
try { recognition.start() } catch (cannotStart) {
|
|
1029
1097
|
options.onError(String(cannotStart && cannotStart.message || cannotStart))
|
|
@@ -1042,7 +1110,7 @@ return stopPromise
|
|
|
1042
1110
|
abort() {
|
|
1043
1111
|
stopped = true
|
|
1044
1112
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1045
|
-
try { recognition.abort() } catch (already) {
|
|
1113
|
+
try { recognition.abort() } catch (already) { }
|
|
1046
1114
|
},
|
|
1047
1115
|
}
|
|
1048
1116
|
}
|
|
@@ -1315,11 +1383,11 @@ modelMap,
|
|
|
1315
1383
|
function teardown(rec) {
|
|
1316
1384
|
if (!rec) return
|
|
1317
1385
|
if (rec.wsStream) { try { rec.wsStream.close() } catch (_) {} rec.wsStream = null }
|
|
1318
|
-
try { rec.stream.getTracks().forEach((t) => t.stop()) } catch (e) {
|
|
1319
|
-
if (rec.srcNode) { try { rec.srcNode.disconnect() } catch (e) {
|
|
1320
|
-
if (rec.filterNode) { try { rec.filterNode.disconnect() } catch (e) {
|
|
1321
|
-
if (rec.analyser) { try { rec.analyser.disconnect() } catch (e) {
|
|
1322
|
-
if (rec.audioCtx) { try { rec.audioCtx.close() } catch (e) {
|
|
1386
|
+
try { rec.stream.getTracks().forEach((t) => t.stop()) } catch (e) { }
|
|
1387
|
+
if (rec.srcNode) { try { rec.srcNode.disconnect() } catch (e) { } }
|
|
1388
|
+
if (rec.filterNode) { try { rec.filterNode.disconnect() } catch (e) { } }
|
|
1389
|
+
if (rec.analyser) { try { rec.analyser.disconnect() } catch (e) { } }
|
|
1390
|
+
if (rec.audioCtx) { try { rec.audioCtx.close() } catch (e) { } }
|
|
1323
1391
|
}
|
|
1324
1392
|
voice.teardownRec = teardown
|
|
1325
1393
|
function waitStop(recorder) {
|
|
@@ -1372,7 +1440,7 @@ filter.Q.value = 0.707
|
|
|
1372
1440
|
src.connect(filter)
|
|
1373
1441
|
lastNode = filter
|
|
1374
1442
|
rec.filterNode = filter
|
|
1375
|
-
} catch (e) {
|
|
1443
|
+
} catch (e) { }
|
|
1376
1444
|
rec.analyser = rec.audioCtx.createAnalyser()
|
|
1377
1445
|
rec.analyser.fftSize = 128
|
|
1378
1446
|
lastNode.connect(rec.analyser)
|
|
@@ -1481,7 +1549,7 @@ rec.streamMs = 0
|
|
|
1481
1549
|
if (!rec.closing && !rec.cancelled) {
|
|
1482
1550
|
try {
|
|
1483
1551
|
if (rec.recorder && rec.recorder.state === 'inactive') rec.recorder.start()
|
|
1484
|
-
} catch (e) {
|
|
1552
|
+
} catch (e) { }
|
|
1485
1553
|
}
|
|
1486
1554
|
rec.cutting = false
|
|
1487
1555
|
if (rec.cancelled || blob.size < 600) return // cancelled or too short — not speech
|
|
@@ -1505,7 +1573,8 @@ if (promptInfo && submitToStructuredPrompt(text, promptInfo)) {
|
|
|
1505
1573
|
return
|
|
1506
1574
|
}
|
|
1507
1575
|
}
|
|
1508
|
-
if (action === 'send' || action === 'clear' || action === 'newline' || action === 'undo_chunk') {
|
|
1576
|
+
if (action === 'send' || action === 'clear' || action === 'newline' || action === 'undo_chunk' || action === 'stop_generation' || action === 'switch_dictation' || action === 'switch_voice_note' || action === 'new_chat') {
|
|
1577
|
+
playAudioCue('success', { enabled: voice.settings?.audioFeedback !== false })
|
|
1509
1578
|
executeVoiceAction(action, text, target)
|
|
1510
1579
|
return
|
|
1511
1580
|
}
|
|
@@ -1622,6 +1691,7 @@ return
|
|
|
1622
1691
|
}
|
|
1623
1692
|
}
|
|
1624
1693
|
announceVoice('start')
|
|
1694
|
+
playAudioCue('start', { enabled: voice.settings?.audioFeedback !== false })
|
|
1625
1695
|
dictationQueue = Promise.resolve()
|
|
1626
1696
|
voice.set({ phase: 'recording', mode, error: '', levels: [], caption: '', interimTranscript: '' })
|
|
1627
1697
|
modeChain(mode).then((info) => {
|
|
@@ -1650,6 +1720,7 @@ voice.set({ phase: 'error', error: String(err && err.message ? err.message : err
|
|
|
1650
1720
|
function startDictation() { startRecording('dictation') }
|
|
1651
1721
|
function startMessage() { startRecording('message') }
|
|
1652
1722
|
function cancelCurrent() {
|
|
1723
|
+
playAudioCue('stop', { enabled: voice.settings?.audioFeedback !== false })
|
|
1653
1724
|
voice.activeOpId = (voice.activeOpId || 0) + 1
|
|
1654
1725
|
announceVoice('end')
|
|
1655
1726
|
focusComposer()
|
|
@@ -1668,10 +1739,11 @@ rec.closing = true
|
|
|
1668
1739
|
const stopped = waitStop(rec.recorder)
|
|
1669
1740
|
try {
|
|
1670
1741
|
if (rec.recorder && rec.recorder.state !== 'inactive') rec.recorder.stop()
|
|
1671
|
-
} catch (e) {
|
|
1742
|
+
} catch (e) { }
|
|
1672
1743
|
stopped.then(() => { teardown(rec); voice.rec = null; voice.set({ phase: 'idle', error: '' }) })
|
|
1673
1744
|
}
|
|
1674
1745
|
function stopCurrent() {
|
|
1746
|
+
playAudioCue('stop', { enabled: voice.settings?.audioFeedback !== false })
|
|
1675
1747
|
announceVoice('end')
|
|
1676
1748
|
focusComposer()
|
|
1677
1749
|
if (voice.browser) {
|
|
@@ -1714,7 +1786,7 @@ const mode = rec.mode
|
|
|
1714
1786
|
const stopped = waitStop(rec.recorder)
|
|
1715
1787
|
try {
|
|
1716
1788
|
if (rec.recorder && rec.recorder.state !== 'inactive') rec.recorder.stop()
|
|
1717
|
-
} catch (e) {
|
|
1789
|
+
} catch (e) { }
|
|
1718
1790
|
stopped.then(async () => {
|
|
1719
1791
|
if (voice.disposed || rec.cancelled || voice.activeOpId !== opId) {
|
|
1720
1792
|
teardown(rec)
|
|
@@ -1760,7 +1832,7 @@ voice.set({ phase: 'idle' })
|
|
|
1760
1832
|
return
|
|
1761
1833
|
}
|
|
1762
1834
|
}
|
|
1763
|
-
if (action === 'send' || action === 'clear' || action === 'newline' || action === 'undo_chunk') {
|
|
1835
|
+
if (action === 'send' || action === 'clear' || action === 'newline' || action === 'undo_chunk' || action === 'stop_generation' || action === 'switch_dictation' || action === 'switch_voice_note' || action === 'new_chat') {
|
|
1764
1836
|
executeVoiceAction(action, text, target)
|
|
1765
1837
|
return
|
|
1766
1838
|
}
|
|
@@ -1802,41 +1874,6 @@ await processTail()
|
|
|
1802
1874
|
}
|
|
1803
1875
|
})
|
|
1804
1876
|
}
|
|
1805
|
-
function clearDraft(target) {
|
|
1806
|
-
const activeTarget = target || voice._activeTarget
|
|
1807
|
-
const actions = (activeTarget && activeTarget.actions) || voice.inputActions
|
|
1808
|
-
if (actions && typeof actions.setDraft === 'function') actions.setDraft('')
|
|
1809
|
-
}
|
|
1810
|
-
function executeVoiceAction(action, rawText, target) {
|
|
1811
|
-
const activeTarget = target || voice._activeTarget
|
|
1812
|
-
const actions = (activeTarget && activeTarget.actions) || voice.inputActions
|
|
1813
|
-
if (action === 'send') {
|
|
1814
|
-
const text = rawText.replace(/(^|[\s,.!?])(отправь|пошли|send)([\s,.!?]|$)/gi, '').trim()
|
|
1815
|
-
if (text) appendDraft(text, activeTarget)
|
|
1816
|
-
if (typeof actions?.submit === 'function') {
|
|
1817
|
-
actions.submit()
|
|
1818
|
-
}
|
|
1819
|
-
voice.set({ phase: 'idle' })
|
|
1820
|
-
} else if (action === 'clear') {
|
|
1821
|
-
clearDraft(activeTarget)
|
|
1822
|
-
voice.set({ phase: 'idle' })
|
|
1823
|
-
} else if (action === 'newline') {
|
|
1824
|
-
const payload = (rawText.replace(/(^|[\s,.!?])(с новой строки|новая строка|абзац|new line|paragraph)([\s,.!?]|$)/gi, '').trim())
|
|
1825
|
-
appendDraft(payload, activeTarget)
|
|
1826
|
-
voice.set({ phase: 'idle' })
|
|
1827
|
-
} else if (action === 'undo_chunk') {
|
|
1828
|
-
undoLastInsert().then((msg) => {
|
|
1829
|
-
voice.lastUndoNotice = msg
|
|
1830
|
-
voice.notify()
|
|
1831
|
-
setTimeout(() => {
|
|
1832
|
-
if (voice.lastUndoNotice === msg) {
|
|
1833
|
-
voice.lastUndoNotice = ''
|
|
1834
|
-
voice.notify()
|
|
1835
|
-
}
|
|
1836
|
-
}, 3500)
|
|
1837
|
-
})
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
1877
|
function submitPending() {
|
|
1841
1878
|
submitPendingPreview(voice)
|
|
1842
1879
|
}
|
|
@@ -1847,7 +1884,7 @@ function runSessionCommand(cmd) {
|
|
|
1847
1884
|
if (cmd === 'send') submitPending()
|
|
1848
1885
|
else if (cmd === 'cancel') cancelCurrent()
|
|
1849
1886
|
else if (cmd === 'stop') cancelCurrent()
|
|
1850
|
-
else if (cmd === 'continue') {
|
|
1887
|
+
else if (cmd === 'continue') { }
|
|
1851
1888
|
else if (cmd === 'undo_chunk') { executeVoiceAction('undo_chunk') }
|
|
1852
1889
|
}
|
|
1853
1890
|
function keepPending() {
|
|
@@ -1971,7 +2008,12 @@ const HOLD_THRESHOLD_MS = 350
|
|
|
1971
2008
|
const hold = { active: false, mode: null, startedAt: 0, armed: false }
|
|
1972
2009
|
let activePointerCleanup = null
|
|
1973
2010
|
function beginHold(mode, pointerEvent) {
|
|
1974
|
-
if (hold.armed || (voice.phase !== 'idle' && voice.phase !== 'error'))
|
|
2011
|
+
if (hold.armed || (voice.phase !== 'idle' && voice.phase !== 'error')) {
|
|
2012
|
+
if (voice.phase === 'recording' || voice.phase === 'pending') {
|
|
2013
|
+
stopCurrent()
|
|
2014
|
+
}
|
|
2015
|
+
return
|
|
2016
|
+
}
|
|
1975
2017
|
hold.armed = true
|
|
1976
2018
|
hold.mode = mode
|
|
1977
2019
|
hold.startedAt = Date.now()
|
|
@@ -2004,20 +2046,24 @@ voice.notify()
|
|
|
2004
2046
|
function endHold(cancelled) {
|
|
2005
2047
|
if (activePointerCleanup) { try { activePointerCleanup() } catch (e) {} }
|
|
2006
2048
|
if (!hold.armed) return
|
|
2049
|
+
const wasHeld = hold.active
|
|
2007
2050
|
hold.armed = false
|
|
2008
2051
|
voice.holding = false
|
|
2009
2052
|
voice.notify()
|
|
2010
|
-
if (cancelled)
|
|
2011
|
-
|
|
2053
|
+
if (cancelled) {
|
|
2054
|
+
cancelCurrent()
|
|
2055
|
+
} else if (wasHeld) {
|
|
2056
|
+
stopCurrent()
|
|
2057
|
+
}
|
|
2012
2058
|
}
|
|
2013
2059
|
let activeHotkeyCleanup = null
|
|
2014
2060
|
function clearGlobalHotkey() {
|
|
2015
2061
|
if (typeof activeHotkeyCleanup === 'function') {
|
|
2016
|
-
try { activeHotkeyCleanup() } catch (_) {
|
|
2062
|
+
try { activeHotkeyCleanup() } catch (_) { }
|
|
2017
2063
|
activeHotkeyCleanup = null
|
|
2018
2064
|
}
|
|
2019
2065
|
if (typeof window !== 'undefined' && typeof window.__dsh_voice_hotkey_cleanup === 'function') {
|
|
2020
|
-
try { window.__dsh_voice_hotkey_cleanup() } catch (_) {
|
|
2066
|
+
try { window.__dsh_voice_hotkey_cleanup() } catch (_) { }
|
|
2021
2067
|
window.__dsh_voice_hotkey_cleanup = null
|
|
2022
2068
|
}
|
|
2023
2069
|
}
|
|
@@ -2305,12 +2351,54 @@ p.sessionMismatch
|
|
|
2305
2351
|
: null,
|
|
2306
2352
|
)
|
|
2307
2353
|
}
|
|
2354
|
+
function clearDraft(target) {
|
|
2355
|
+
const actions = (target || voice._activeTarget)?.actions || voice.inputActions
|
|
2356
|
+
if (typeof actions?.setDraft === 'function') actions.setDraft('')
|
|
2357
|
+
}
|
|
2358
|
+
function executeVoiceAction(action, rawText, target) {
|
|
2359
|
+
const activeTarget = target || voice._activeTarget
|
|
2360
|
+
const acts = (activeTarget && activeTarget.actions) || voice.inputActions
|
|
2361
|
+
if (action === 'send') {
|
|
2362
|
+
const text = rawText.replace(/(^|[\s,.!?])(отправь|пошли|send)([\s,.!?]|$)/gi, '').trim()
|
|
2363
|
+
if (text) appendDraft(text, activeTarget)
|
|
2364
|
+
if (typeof acts?.submit === 'function') acts.submit()
|
|
2365
|
+
voice.set({ phase: 'idle' })
|
|
2366
|
+
} else if (action === 'clear') {
|
|
2367
|
+
clearDraft(activeTarget)
|
|
2368
|
+
voice.set({ phase: 'idle' })
|
|
2369
|
+
} else if (action === 'stop_generation') {
|
|
2370
|
+
if (acts?.stop) acts.stop()
|
|
2371
|
+
else {
|
|
2372
|
+
const btn = typeof document !== 'undefined' && document.querySelector('[data-action="stop"], [aria-label*="Stop"], button.dsw-stop-btn, .chat-stop-btn')
|
|
2373
|
+
if (btn) btn.click()
|
|
2374
|
+
}
|
|
2375
|
+
voice.set({ phase: 'idle' })
|
|
2376
|
+
} else if (action === 'switch_dictation') {
|
|
2377
|
+
voice.activeMode = 'dictation'; voice.notify()
|
|
2378
|
+
} else if (action === 'switch_voice_note') {
|
|
2379
|
+
voice.activeMode = 'note'; voice.notify()
|
|
2380
|
+
} else if (action === 'new_chat') {
|
|
2381
|
+
const newBtn = typeof document !== 'undefined' && document.querySelector('[data-action="new-chat"], button.new-chat-btn, [aria-label*="New topic"], [aria-label*="Новый диалог"]')
|
|
2382
|
+
if (newBtn) newBtn.click()
|
|
2383
|
+
voice.set({ phase: 'idle' })
|
|
2384
|
+
} else if (action === 'newline') {
|
|
2385
|
+
const payload = rawText.replace(/(^|[\s,.!?])(с новой строки|новая строка|абзац|new line|paragraph)([\s,.!?]|$)/gi, '').trim()
|
|
2386
|
+
appendDraft(payload, activeTarget)
|
|
2387
|
+
voice.set({ phase: 'idle' })
|
|
2388
|
+
} else if (action === 'undo_chunk') {
|
|
2389
|
+
undoLastInsert().then((msg) => {
|
|
2390
|
+
voice.lastUndoNotice = msg; voice.notify()
|
|
2391
|
+
setTimeout(() => { if (voice.lastUndoNotice === msg) { voice.lastUndoNotice = ''; voice.notify() } }, 3500)
|
|
2392
|
+
})
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2308
2395
|
const DICTATION_MODES = ['clean', 'task', 'note', 'verbatim']
|
|
2309
2396
|
function getDictationModeLabel(m, t) {
|
|
2310
2397
|
const trans = t || moduleT
|
|
2311
2398
|
if (m === 'verbatim') return trans('modeVerbatim')
|
|
2312
2399
|
if (m === 'task') return trans('modeTask')
|
|
2313
2400
|
if (m === 'note') return trans('modeNote')
|
|
2401
|
+
if (m === 'bug') return trans('modeBug')
|
|
2314
2402
|
return trans('modeClean')
|
|
2315
2403
|
}
|
|
2316
2404
|
function cycleDictationMode() {
|
|
@@ -2333,7 +2421,7 @@ if (pick) {
|
|
|
2333
2421
|
_accentColorCache = { color: pick, expires: now + 1000 }
|
|
2334
2422
|
return pick
|
|
2335
2423
|
}
|
|
2336
|
-
} catch (noTheme) {
|
|
2424
|
+
} catch (noTheme) { }
|
|
2337
2425
|
return fallback || voice.waveColor || 'currentColor'
|
|
2338
2426
|
}
|
|
2339
2427
|
function softColor(fallback) {
|
|
@@ -2347,7 +2435,7 @@ if (pick) {
|
|
|
2347
2435
|
_softColorCache = { color: pick, expires: now + 1000 }
|
|
2348
2436
|
return pick
|
|
2349
2437
|
}
|
|
2350
|
-
} catch (noTheme) {
|
|
2438
|
+
} catch (noTheme) { }
|
|
2351
2439
|
return fallback || voice.waveColor || 'currentColor'
|
|
2352
2440
|
}
|
|
2353
2441
|
function drawLiquidWave(g, w, h, levels, color, time) {
|
|
@@ -2827,7 +2915,7 @@ liveInterimPreview: data && data.liveInterimPreview !== false,
|
|
|
2827
2915
|
structuredPromptVoice: data && data.structuredPromptVoice !== false,
|
|
2828
2916
|
})
|
|
2829
2917
|
})
|
|
2830
|
-
.catch(() => {
|
|
2918
|
+
.catch(() => { })
|
|
2831
2919
|
}
|
|
2832
2920
|
reload()
|
|
2833
2921
|
window.addEventListener('dsh-voice:settings-saved', reload)
|
|
@@ -3215,7 +3303,7 @@ const updated = { ...prompts, [key]: val }
|
|
|
3215
3303
|
setTop('dictationPrompts', updated)
|
|
3216
3304
|
}
|
|
3217
3305
|
const resetPrompts = () => {
|
|
3218
|
-
setTop('dictationPrompts', { clean: '', task: '', note: '' })
|
|
3306
|
+
setTop('dictationPrompts', { clean: '', task: '', note: '', bug: '' })
|
|
3219
3307
|
}
|
|
3220
3308
|
return h('div', { className: 'cb-section-card' },
|
|
3221
3309
|
h('div', { className: 'cb-section-title' },
|
|
@@ -3223,7 +3311,7 @@ h('span', null, '🎙️ ' + t('dictationModeTitle')),
|
|
|
3223
3311
|
),
|
|
3224
3312
|
h('div', { className: 'cb-field-desc' }, t('dictationModeDesc')),
|
|
3225
3313
|
h('div', { className: 'cb-grid-2', style: { marginTop: '8px' } },
|
|
3226
|
-
['clean', 'task', 'note', 'verbatim'].map((m) =>
|
|
3314
|
+
['clean', 'task', 'bug', 'note', 'verbatim'].map((m) =>
|
|
3227
3315
|
h('label', { key: m, className: 'cb-check-label' },
|
|
3228
3316
|
h('input', {
|
|
3229
3317
|
type: 'radio',
|
|
@@ -3273,6 +3361,17 @@ onChange: (e) => setPrompt('task', e.target.value),
|
|
|
3273
3361
|
}),
|
|
3274
3362
|
),
|
|
3275
3363
|
h('div', null,
|
|
3364
|
+
h('label', { className: 'cb-label' }, t('promptBug')),
|
|
3365
|
+
h('textarea', {
|
|
3366
|
+
className: 'cb-input',
|
|
3367
|
+
style: { minHeight: '48px', resize: 'vertical' },
|
|
3368
|
+
value: prompts.bug || '',
|
|
3369
|
+
placeholder: t('promptBugPlaceholder'),
|
|
3370
|
+
disabled: !writable,
|
|
3371
|
+
onChange: (e) => setPrompt('bug', e.target.value),
|
|
3372
|
+
}),
|
|
3373
|
+
),
|
|
3374
|
+
h('div', null,
|
|
3276
3375
|
h('label', { className: 'cb-label' }, t('promptNote')),
|
|
3277
3376
|
h('textarea', {
|
|
3278
3377
|
className: 'cb-input',
|
|
@@ -3694,8 +3793,8 @@ const toggleTestMic = async () => {
|
|
|
3694
3793
|
if (testingMic) {
|
|
3695
3794
|
if (testRef.current) {
|
|
3696
3795
|
testRef.current.active = false
|
|
3697
|
-
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) {
|
|
3698
|
-
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) {
|
|
3796
|
+
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) { }
|
|
3797
|
+
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) { } }
|
|
3699
3798
|
testRef.current = null
|
|
3700
3799
|
}
|
|
3701
3800
|
setTestingMic(false)
|
|
@@ -3720,7 +3819,7 @@ filter.frequency.value = 80
|
|
|
3720
3819
|
filter.Q.value = 0.707
|
|
3721
3820
|
src.connect(filter)
|
|
3722
3821
|
lastNode = filter
|
|
3723
|
-
} catch (e) {
|
|
3822
|
+
} catch (e) { }
|
|
3724
3823
|
const analyser = audioCtx.createAnalyser()
|
|
3725
3824
|
analyser.fftSize = 128
|
|
3726
3825
|
lastNode.connect(analyser)
|
|
@@ -3745,8 +3844,8 @@ React.useEffect(() => {
|
|
|
3745
3844
|
return () => {
|
|
3746
3845
|
if (testRef.current) {
|
|
3747
3846
|
testRef.current.active = false
|
|
3748
|
-
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) {
|
|
3749
|
-
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) {
|
|
3847
|
+
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) { }
|
|
3848
|
+
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) { } }
|
|
3750
3849
|
testRef.current = null
|
|
3751
3850
|
}
|
|
3752
3851
|
}
|
|
@@ -4160,13 +4259,13 @@ ctx.configForms.describe().load()
|
|
|
4160
4259
|
} else if (ctx.settingsScope && typeof ctx.settingsScope.describe === 'function') {
|
|
4161
4260
|
ctx.settingsScope.describe().load()
|
|
4162
4261
|
}
|
|
4163
|
-
} catch (e) {
|
|
4262
|
+
} catch (e) { }
|
|
4164
4263
|
}, 1000)
|
|
4165
4264
|
return () => clearInterval(timer)
|
|
4166
4265
|
}, [ready])
|
|
4167
4266
|
const deepClone = (obj) => {
|
|
4168
4267
|
if (typeof structuredClone === 'function') {
|
|
4169
|
-
try { return structuredClone(obj) } catch (e) {
|
|
4268
|
+
try { return structuredClone(obj) } catch (e) { }
|
|
4170
4269
|
}
|
|
4171
4270
|
try { return JSON.parse(JSON.stringify(obj)) } catch (e) { return Object.assign({}, obj) }
|
|
4172
4271
|
}
|
|
@@ -4230,6 +4329,7 @@ autoSendVisualRing: val.autoSendVisualRing !== false,
|
|
|
4230
4329
|
voiceActions: val.voiceActions !== false,
|
|
4231
4330
|
techJargonCorrection: val.techJargonCorrection !== false,
|
|
4232
4331
|
liveInterimPreview: val.liveInterimPreview !== false,
|
|
4332
|
+
audioFeedback: val.audioFeedback !== false,
|
|
4233
4333
|
structuredPromptVoice: val.structuredPromptVoice !== false,
|
|
4234
4334
|
dictationMode: val.dictationMode || 'clean',
|
|
4235
4335
|
dictationPrompts: val.dictationPrompts || {},
|
|
@@ -4307,7 +4407,6 @@ for (const k of Object.keys(draft)) {
|
|
|
4307
4407
|
try {
|
|
4308
4408
|
await scope.set(k, draft[k])
|
|
4309
4409
|
} catch (e) {
|
|
4310
|
-
/* best effort on loopback */
|
|
4311
4410
|
}
|
|
4312
4411
|
}
|
|
4313
4412
|
}
|
|
@@ -4343,9 +4442,10 @@ autoSendVisualRing: d.autoSendVisualRing !== false,
|
|
|
4343
4442
|
voiceActions: d.voiceActions !== false,
|
|
4344
4443
|
techJargonCorrection: d.techJargonCorrection !== false,
|
|
4345
4444
|
liveInterimPreview: d.liveInterimPreview !== false,
|
|
4445
|
+
audioFeedback: d.audioFeedback !== false,
|
|
4346
4446
|
structuredPromptVoice: d.structuredPromptVoice !== false,
|
|
4347
4447
|
})
|
|
4348
|
-
try { window.dispatchEvent(new CustomEvent('dsh-voice:settings-saved')) } catch (noEvents) {
|
|
4448
|
+
try { window.dispatchEvent(new CustomEvent('dsh-voice:settings-saved')) } catch (noEvents) { }
|
|
4349
4449
|
setSaved(true); setJargonInput(null)
|
|
4350
4450
|
setTimeout(() => setSaved(false), 2000)
|
|
4351
4451
|
fetchStatus()
|
|
@@ -4587,6 +4687,15 @@ onChange: (e) => setTop('structuredPromptVoice', e.target.checked),
|
|
|
4587
4687
|
}),
|
|
4588
4688
|
t('structuredPromptVoice'),
|
|
4589
4689
|
),
|
|
4690
|
+
h('label', { className: 'cb-check-label' },
|
|
4691
|
+
h('input', {
|
|
4692
|
+
type: 'checkbox',
|
|
4693
|
+
checked: draft ? draft.audioFeedback !== false : true,
|
|
4694
|
+
disabled: !writable,
|
|
4695
|
+
onChange: (e) => setTop('audioFeedback', e.target.checked),
|
|
4696
|
+
}),
|
|
4697
|
+
t('audioFeedback'),
|
|
4698
|
+
),
|
|
4590
4699
|
),
|
|
4591
4700
|
),
|
|
4592
4701
|
h(DictationModesSection, {
|
package/lib/dictation-modes.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
// lib/dictation-modes.js — Dictation post-processing modes (#264)
|
|
1
|
+
// lib/dictation-modes.js — Dictation post-processing modes (#264, #321)
|
|
2
2
|
|
|
3
3
|
export const DICTATION_MODES = ['verbatim', 'clean', 'task', 'note']
|
|
4
|
+
export const ALL_DICTATION_MODES = ['verbatim', 'clean', 'task', 'note', 'bug']
|
|
4
5
|
|
|
5
6
|
export const DEFAULT_DICTATION_PROMPTS = {
|
|
6
7
|
clean: 'Fix the punctuation and spelling of this dictated text and remove filler words ("um", "uh", etc.). Keep the original language, technical terms, and meaning intact without adding facts. Reply with the clean text only:\n\n{text}',
|
|
7
8
|
task: 'Convert the following dictated request into a clear, structured agent task with: Problem/Goal, Expected Outcome, Constraints, Acceptance Criteria. Do not invent details not mentioned in the dictation. Keep technical identifiers intact. Reply with the structured task only:\n\n{text}',
|
|
8
9
|
note: 'Extract key points, main ideas, and action items from the following dictation. Only include action items that were explicitly mentioned. Keep original terminology intact. Reply with the structured note only:\n\n{text}',
|
|
10
|
+
bug: 'Convert the following dictated problem into a concise, actionable bug report with: Problem Summary, Observed Behavior / Error, Steps to Reproduce, Expected Behavior. Keep technical identifiers, paths, and error codes verbatim. Reply with the structured bug report only:\n\n{text}',
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Resolve prompt instruction for a dictation sub-mode.
|
|
13
|
-
* @param {string} mode 'verbatim' | 'clean' | 'task' | 'note'
|
|
15
|
+
* @param {string} mode 'verbatim' | 'clean' | 'task' | 'note' | 'bug'
|
|
14
16
|
* @param {Record<string, string>} [customPrompts]
|
|
15
17
|
* @param {string} text Dictated text to format
|
|
16
18
|
* @returns {string|null} null for verbatim (0 LLM calls), prompt string for LLM modes
|
|
17
19
|
*/
|
|
18
20
|
export function resolveDictationPrompt(mode, customPrompts, text) {
|
|
19
|
-
const m =
|
|
21
|
+
const m = ALL_DICTATION_MODES.includes(mode) ? mode : 'clean'
|
|
20
22
|
if (m === 'verbatim') return null
|
|
21
23
|
const template = (customPrompts && typeof customPrompts[m] === 'string' && customPrompts[m].trim())
|
|
22
24
|
? customPrompts[m]
|
|
23
25
|
: DEFAULT_DICTATION_PROMPTS[m]
|
|
26
|
+
if (!template) return text
|
|
24
27
|
if (template.includes('{text}')) {
|
|
25
28
|
return template.replaceAll('{text}', text)
|
|
26
29
|
}
|
package/lib/normalize.js
CHANGED
|
@@ -143,9 +143,21 @@ export function extractVoiceActions(text) {
|
|
|
143
143
|
if (/^(отмена|cancel|discard|取消|算了)$/i.test(lower)) {
|
|
144
144
|
return { text: '', action: 'cancel' }
|
|
145
145
|
}
|
|
146
|
-
if (/^(
|
|
146
|
+
if (/^(очисти|очистить|сотри всё|удали всё|clear|clear composer|clear all|清空|清除)$/i.test(lower)) {
|
|
147
147
|
return { text: '', action: 'clear' }
|
|
148
148
|
}
|
|
149
|
+
if (/^(останови генерацию|останови агента|прерви ответ|прерви генерацию|стоп агент|stop generation|stop agent|停止生成)$/i.test(lower)) {
|
|
150
|
+
return { text: '', action: 'stop_generation' }
|
|
151
|
+
}
|
|
152
|
+
if (/^(переключи на диктовку|режим диктовки|switch to dictation|dictation mode|切换到听写)$/i.test(lower)) {
|
|
153
|
+
return { text: '', action: 'switch_dictation' }
|
|
154
|
+
}
|
|
155
|
+
if (/^(переключи на голосовое|режим голосового|switch to voice note|voice note mode|切换到语音)$/i.test(lower)) {
|
|
156
|
+
return { text: '', action: 'switch_voice_note' }
|
|
157
|
+
}
|
|
158
|
+
if (/^(новый диалог|новый чат|new chat|new topic|新建对话)$/i.test(lower)) {
|
|
159
|
+
return { text: '', action: 'new_chat' }
|
|
160
|
+
}
|
|
149
161
|
if (/^(новая строка|с новой строки|new line|newline|换行|新行)$/i.test(lower)) {
|
|
150
162
|
return { text: '', action: 'newline' }
|
|
151
163
|
}
|
|
@@ -161,11 +173,27 @@ export function extractVoiceActions(text) {
|
|
|
161
173
|
if (trailingCancel.test(raw)) {
|
|
162
174
|
return { text: raw.replace(trailingCancel, '').trim(), action: 'cancel' }
|
|
163
175
|
}
|
|
176
|
+
const trailingClear = /[\s,]+(очисти|очистить|сотри всё|удали всё|clear all|清空)[.!?…]*$/i
|
|
177
|
+
if (trailingClear.test(raw)) {
|
|
178
|
+
return { text: raw.replace(trailingClear, '').trim(), action: 'clear' }
|
|
179
|
+
}
|
|
180
|
+
const trailingStopAgent = /[\s,]+(останови генерацию|останови агента|прерви ответ|стоп агент|stop generation|stop agent|停止生成)[.!?…]*$/i
|
|
181
|
+
if (trailingStopAgent.test(raw)) {
|
|
182
|
+
return { text: raw.replace(trailingStopAgent, '').trim(), action: 'stop_generation' }
|
|
183
|
+
}
|
|
184
|
+
const trailingSwitchDictation = /[\s,]+(переключи на диктовку|режим диктовки|switch to dictation|切换到听写)[.!?…]*$/i
|
|
185
|
+
if (trailingSwitchDictation.test(raw)) {
|
|
186
|
+
return { text: raw.replace(trailingSwitchDictation, '').trim(), action: 'switch_dictation' }
|
|
187
|
+
}
|
|
188
|
+
const trailingSwitchNote = /[\s,]+(переключи на голосовое|режим голосового|switch to voice note|切换到语音)[.!?…]*$/i
|
|
189
|
+
if (trailingSwitchNote.test(raw)) {
|
|
190
|
+
return { text: raw.replace(trailingSwitchNote, '').trim(), action: 'switch_voice_note' }
|
|
191
|
+
}
|
|
164
192
|
const trailingNewline = /[\s,]+(новая строка|с новой строки|new line|换行|新行)[.!?…]*$/i
|
|
165
193
|
if (trailingNewline.test(raw)) {
|
|
166
194
|
return { text: raw.replace(trailingNewline, '').trim() + '\n', action: 'newline' }
|
|
167
195
|
}
|
|
168
|
-
const trailingUndo = /[\s,]+(отмени последнее|сотри последнее|удали последнее|откати последнее|undo last|undo chunk
|
|
196
|
+
const trailingUndo = /[\s,]+(отмени последнее|сотри последнее|удали последнее|откати последнее|undo|undo last|undo chunk|撤销|撤销上一句)[.!?…]*$/i
|
|
169
197
|
if (trailingUndo.test(raw)) {
|
|
170
198
|
return { text: raw.replace(trailingUndo, '').trim(), action: 'undo_chunk' }
|
|
171
199
|
}
|
|
@@ -173,11 +201,102 @@ export function extractVoiceActions(text) {
|
|
|
173
201
|
return { text: raw, action: null }
|
|
174
202
|
}
|
|
175
203
|
|
|
204
|
+
|
|
205
|
+
// --- Code Casing and Filler Cleaner (#320, #321) ---
|
|
206
|
+
|
|
207
|
+
const TRANSLIT = {
|
|
208
|
+
'а':'a','б':'b','в':'v','г':'g','д':'d','е':'e','ё':'yo','ж':'zh','з':'z','и':'i','й':'y',
|
|
209
|
+
'к':'k','л':'l','м':'m','н':'n','о':'o','п':'p','р':'r','с':'s','т':'t','у':'u','ф':'f',
|
|
210
|
+
'х':'h','ц':'ts','ч':'ch','ш':'sh','щ':'sch','ъ':'','ы':'y','ь':'','э':'e','ю':'yu','я':'ya'
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const COMMON_DEV_WORDS = {
|
|
214
|
+
'юзер': 'user', 'айди': 'id', 'нейм': 'name', 'дата': 'data', 'инфо': 'info', 'токен': 'token',
|
|
215
|
+
'конфиг': 'config', 'статус': 'status', 'счетчик': 'count', 'ошибка': 'error', 'сообщение': 'message',
|
|
216
|
+
'кнопка': 'button', 'карта': 'card', 'список': 'list', 'значение': 'value', 'ключ': 'key',
|
|
217
|
+
'макс': 'max', 'мин': 'min', 'ретрайс': 'retries', 'лимит': 'limit', 'время': 'time', 'таймаут': 'timeout',
|
|
218
|
+
'путь': 'path', 'индекс': 'index', 'хэндлер': 'handler', 'сервис': 'service', 'клиент': 'client'
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function transliterateDevWord(w) {
|
|
222
|
+
const low = String(w || '').toLowerCase()
|
|
223
|
+
if (COMMON_DEV_WORDS[low]) return COMMON_DEV_WORDS[low]
|
|
224
|
+
return low.split('').map((c) => TRANSLIT[c] || c).join('')
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function wordsOf(str) {
|
|
228
|
+
return String(str || '').trim().split(/[\s_-]+/).filter(Boolean).map(transliterateDevWord)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function toCamelCase(str) {
|
|
232
|
+
const ws = wordsOf(str)
|
|
233
|
+
if (!ws.length) return ''
|
|
234
|
+
return ws[0].toLowerCase() + ws.slice(1).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join('')
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function toPascalCase(str) {
|
|
238
|
+
const ws = wordsOf(str)
|
|
239
|
+
return ws.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join('')
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function toSnakeCase(str) {
|
|
243
|
+
return wordsOf(str).map((w) => w.toLowerCase()).join('_')
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function toConstantCase(str) {
|
|
247
|
+
return wordsOf(str).map((w) => w.toUpperCase()).join('_')
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function toKebabCase(str) {
|
|
251
|
+
return wordsOf(str).map((w) => w.toLowerCase()).join('-')
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function formatCasing(wordsStr, targetCase) {
|
|
255
|
+
const c = String(targetCase || '').toLowerCase().replace(/\s+/g, '')
|
|
256
|
+
if (c.includes('camel') || c.includes('кэмел')) return toCamelCase(wordsStr)
|
|
257
|
+
if (c.includes('snake') || c.includes('снейк')) return toSnakeCase(wordsStr)
|
|
258
|
+
if (c.includes('constant') || c.includes('констант') || c.includes('upper') || c.includes('апер')) return toConstantCase(wordsStr)
|
|
259
|
+
if (c.includes('kebab') || c.includes('кебаб')) return toKebabCase(wordsStr)
|
|
260
|
+
if (c.includes('pascal') || c.includes('паскаль')) return toPascalCase(wordsStr)
|
|
261
|
+
return wordsStr
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const CASING_TARGETS = '(?:camel[-_\\s]*case|кэмел[-_\\s]*кейс|snake[-_\\s]*case|снейк[-_\\s]*кейс|constant[-_\\s]*case|upper[-_\\s]*snake|константу|константа|апер[-_\\s]*снейк|kebab[-_\\s]*case|кебаб[-_\\s]*кейс|pascal[-_\\s]*case|паскаль[-_\\s]*кейс)'
|
|
265
|
+
|
|
266
|
+
export function applyCodeCasing(text) {
|
|
267
|
+
let t = String(text || '')
|
|
268
|
+
// 1. With explicit keyword: declare variable user id in camelCase
|
|
269
|
+
const keywordRe = new RegExp(`(^|[.,!?\\s])(?:переменную|переменная|поле|функцию|функция|метод|константу|константа|класс|компонент|тип|variable|function|method|constant|class|component)\\s+([a-zA-Zа-яА-ЯёЁ0-9_-]+(?:\\s+[a-zA-Zа-яА-ЯёЁ0-9_-]+){0,3})\\s+(?:в|to|in)\\s+(${CASING_TARGETS})(?=[.,!?\\s]|$)`, 'gi')
|
|
270
|
+
t = t.replace(keywordRe, (_, lead, words, targetCase) => (lead || '') + formatCasing(words, targetCase))
|
|
271
|
+
|
|
272
|
+
// 2. Direct suffix: user id in camelCase (1-3 words)
|
|
273
|
+
const suffixRe = new RegExp(`(^|[.,!?\\s])([a-zA-Zа-яА-ЯёЁ0-9_-]+(?:\\s+[a-zA-Zа-яА-ЯёЁ0-9_-]+){0,2})\\s+(?:в|to|in)\\s+(${CASING_TARGETS})(?=[.,!?\\s]|$)`, 'gi')
|
|
274
|
+
t = t.replace(suffixRe, (_, lead, words, targetCase) => (lead || '') + formatCasing(words, targetCase))
|
|
275
|
+
return t
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function cleanFillerWords(text) {
|
|
279
|
+
let t = String(text || '')
|
|
280
|
+
// Deduplicate adjacent repeated words in Cyrillic & Latin
|
|
281
|
+
t = t.replace(/(?<![a-zA-Zа-яА-ЯёЁ0-9])([a-zA-Zа-яА-ЯёЁ0-9]+)\s+\1(?![a-zA-Zа-яА-ЯёЁ0-9])/gi, '$1')
|
|
282
|
+
// Remove multi-word Russian fillers and hesitation sounds
|
|
283
|
+
t = t.replace(/(?<![a-zA-Zа-яА-ЯёЁ0-9])(?:ну\s+типа|как\s+бы|в\s+общем-то|так\s+сказать|короче\s+говоря|ээ+|мм+)(?![a-zA-Zа-яА-ЯёЁ0-9])/gi, '')
|
|
284
|
+
// Remove standalone single-word fillers
|
|
285
|
+
t = t.replace(/(^|[.,!?\s])(?:ну|типа|короче)(?=[.,!?\s]|$)/gi, '$1')
|
|
286
|
+
// English fillers
|
|
287
|
+
t = t.replace(/(^|[.,!?\s])(?:uh+|um+|you\s+know|basically|sort\s+of|kind\s+of)(?=[.,!?\s]|$)/gi, '$1')
|
|
288
|
+
// Clean up duplicate spaces and dangling punctuation
|
|
289
|
+
t = t.replace(/\s+/g, ' ').replace(/\s+([.,!?])/g, '$1').trim()
|
|
290
|
+
return t
|
|
291
|
+
}
|
|
292
|
+
|
|
176
293
|
export function normalizePhrase(text, opts = {}) {
|
|
177
294
|
let out = String(text || '').trim()
|
|
178
295
|
if (!out) return out
|
|
179
296
|
const lang = opts.lang ?? opts.language
|
|
180
297
|
const isRu = opts.isRussian ?? (lang !== undefined ? isRussianLang(lang, out) : true)
|
|
298
|
+
if (opts.cleanFillers ?? true) out = cleanFillerWords(out)
|
|
299
|
+
if (opts.codeCasing ?? true) out = applyCodeCasing(out)
|
|
181
300
|
if (opts.digits && isRu) out = wordsToDigits(out)
|
|
182
301
|
if (opts.commaSpacing) out = fixCommaSpacing(out)
|
|
183
302
|
if (opts.jargon) {
|
package/lib/schema.js
CHANGED
|
@@ -168,14 +168,17 @@ export const BaseConfig = z.object({
|
|
|
168
168
|
.description('Custom jargon replacement dictionary.'),
|
|
169
169
|
liveInterimPreview: z.boolean().default(true)
|
|
170
170
|
.description('Display real-time interim speech preview (ghost text) in the recording pill.'),
|
|
171
|
+
audioFeedback: z.boolean().default(true)
|
|
172
|
+
.description('Play subtle acoustic feedback cues via Web Audio API on start, stop, and success.'),
|
|
171
173
|
structuredPromptVoice: z.boolean().default(true)
|
|
172
174
|
.description('Target voice dictation and numeric choices to active DSH structured prompt modals.'),
|
|
173
|
-
dictationMode: z.union(['verbatim', 'clean', 'task', 'note']).default('clean')
|
|
175
|
+
dictationMode: z.union(['verbatim', 'clean', 'task', 'note', 'bug']).default('clean')
|
|
174
176
|
.description('Dictation post-processing mode: "verbatim", "clean", "task", or "note".'),
|
|
175
177
|
dictationPrompts: z.object({
|
|
176
178
|
clean: z.string().default(''),
|
|
177
179
|
task: z.string().default(''),
|
|
178
180
|
note: z.string().default(''),
|
|
181
|
+
bug: z.string().default(''),
|
|
179
182
|
}).default({})
|
|
180
183
|
.description('Custom prompt templates for dictation modes.'),
|
|
181
184
|
voiceMacros: z.array(VoiceMacro).default([])
|
package/lib/transcribe-core.js
CHANGED
|
@@ -36,6 +36,10 @@ const SESSION_COMMANDS = [
|
|
|
36
36
|
{ re: /^(стоп|stop|хватит|停止|暂停)\s*[.!?]*$/i, cmd: 'stop' },
|
|
37
37
|
{ re: /^(продолжи|continue|продолжай|继续)\s*[.!?]*$/i, cmd: 'continue' },
|
|
38
38
|
{ re: /^(отмени последнее|сотри последнее|удали последнее|откати последнее|undo|undo last|undo chunk|撤销|撤销上一句)\s*[.!?]*$/i, cmd: 'undo_chunk' },
|
|
39
|
+
{ re: /^(очисти|очистить|сотри всё|удали всё|clear|clear all|清空)\s*[.!?]*$/i, cmd: 'clear' },
|
|
40
|
+
{ re: /^(останови генерацию|останови агента|прерви генерацию|стоп агент|stop generation|stop agent|停止生成)\s*[.!?]*$/i, cmd: 'stop_generation' },
|
|
41
|
+
{ re: /^(переключи на диктовку|режим диктовки|switch to dictation|切换到听写)\s*[.!?]*$/i, cmd: 'switch_dictation' },
|
|
42
|
+
{ re: /^(переключи на голосовое|режим голосового|switch to voice note|切换到语音)\s*[.!?]*$/i, cmd: 'switch_voice_note' },
|
|
39
43
|
]
|
|
40
44
|
|
|
41
45
|
/**
|
|
@@ -51,7 +55,7 @@ export function sessionCommand(text) {
|
|
|
51
55
|
return null
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
export const DEFAULT_BILINGUAL_PROMPT = 'TypeScript, Python, JavaScript, Docker, Git commit, PR, push, merge, branch, npm, pnpm, API, JSON, async, await, bug, deploy, Linux, bash. Смешанная речь разработчика: русский язык с английскими терминами, командами и кодом.'
|
|
58
|
+
export const DEFAULT_BILINGUAL_PROMPT = 'TypeScript, Python, JavaScript, Docker, Git commit, PR, push, merge, branch, npm, pnpm, k8s, kubectl, PostgreSQL, Redis, API, JSON, async, await, bug, deploy, Linux, bash. Смешанная речь разработчика: русский язык с английскими терминами, командами и кодом.'
|
|
55
59
|
|
|
56
60
|
export function buildTranscriptionPrompt({
|
|
57
61
|
vocabulary = [],
|
|
@@ -81,7 +85,7 @@ export function buildTranscriptionPrompt({
|
|
|
81
85
|
|
|
82
86
|
const keywords = [...mergedVocab]
|
|
83
87
|
if (bilingualDeveloperPrompt && isRuOrAuto) {
|
|
84
|
-
for (const w of ['Docker', 'Git', 'commit', 'PR', 'merge', 'branch', 'pnpm', 'npm', 'API', 'JSON', 'TypeScript']) {
|
|
88
|
+
for (const w of ['Docker', 'Git', 'commit', 'PR', 'merge', 'branch', 'pnpm', 'npm', 'API', 'JSON', 'TypeScript', 'k8s', 'kubectl', 'PostgreSQL', 'Redis', 'GraphQL', 'Next.js', 'FastAPI', 'rebase', 'cherry-pick']) {
|
|
85
89
|
if (!keywords.includes(w)) keywords.push(w)
|
|
86
90
|
}
|
|
87
91
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-voice",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.53",
|
|
4
4
|
"description": "Voice input for DeepSeek Harness: dictation chunked by pauses and voice messages, each with its own provider fallback chain (Deepgram, Groq, HuggingFace, local whisper.cpp, plus any OpenAI-compatible API of your own).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|