@goodandready/dsh-voice 0.9.52 → 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 +184 -134
- package/lib/normalize.js +30 -2
- package/lib/schema.js +2 -0
- package/lib/transcribe-core.js +4 -0
- 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
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':'
|
|
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
260
|
'modeVerbatim':'逐字直录', 'modeClean':'清爽文本', 'modeTask':'智能体任务', 'modeNote':'便签备忘', 'modeBug':'缺陷报告', 'promptBug':'缺陷报告提示词', 'promptBugPlaceholder':'默认:问题概要、异常现象、复现步骤、预期行为', 'dictationModeTitle':'听写后处理模式',
|
|
261
|
-
'dictationModeDesc':'
|
|
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;
|
|
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,8 +345,33 @@ 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
|
+
}
|
|
348
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(':')))
|
|
349
|
-
const CLIENT_DEV_WORDS = Object.fromEntries('юзер:user,айди:id,нейм:name,дата:data,инфо:info,токен:token,конфиг:config,статус:status,счетчик:count,ошибка:error
|
|
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(':')))
|
|
350
375
|
function transliterateDevWord(w) {
|
|
351
376
|
const low = String(w || '').toLowerCase()
|
|
352
377
|
return CLIENT_DEV_WORDS[low] || low.split('').map((c) => DEV_TRANSLIT[c] || c).join('')
|
|
@@ -367,7 +392,7 @@ const ws = devWordsOf(str)
|
|
|
367
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
|
|
368
393
|
return f ? f(ws) : str
|
|
369
394
|
}
|
|
370
|
-
const CLIENT_CASING_TARGETS = '(?:camel
|
|
395
|
+
const CLIENT_CASING_TARGETS = '(?:(?:camel|кэмел|snake|снейк|constant|upper|kebab|кебаб|pascal|паскаль)[-_\\s]*(?:case|кейс|snake)?|констант(?:у|а)?|апер[-_\\s]*снейк)'
|
|
371
396
|
function applyCodeCasing(text) {
|
|
372
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')
|
|
373
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')
|
|
@@ -617,9 +642,9 @@ window.dispatchEvent(new CustomEvent('dsh:tts:cancel', { bubbles: true }))
|
|
|
617
642
|
window.dispatchEvent(new CustomEvent('dsh:tts:stop', { bubbles: true }))
|
|
618
643
|
const audios = document.querySelectorAll('audio')
|
|
619
644
|
for (const a of audios) {
|
|
620
|
-
if (!a.paused) { try { a.pause() } catch (err) {
|
|
645
|
+
if (!a.paused) { try { a.pause() } catch (err) { } }
|
|
621
646
|
}
|
|
622
|
-
} catch {
|
|
647
|
+
} catch { }
|
|
623
648
|
voice.set({ isTtsSpeaking: false })
|
|
624
649
|
}
|
|
625
650
|
function findActiveStructuredPrompt() {
|
|
@@ -631,7 +656,7 @@ const input = modal.querySelector('textarea, input[type="text"]')
|
|
|
631
656
|
const buttons = Array.from(modal.querySelectorAll('button:not([disabled])'))
|
|
632
657
|
return { modal, input, buttons }
|
|
633
658
|
}
|
|
634
|
-
} catch {
|
|
659
|
+
} catch { }
|
|
635
660
|
return null
|
|
636
661
|
}
|
|
637
662
|
function submitToStructuredPrompt(text, promptInfo) {
|
|
@@ -719,12 +744,12 @@ function focusComposer() {
|
|
|
719
744
|
if (typeof window === 'undefined') return
|
|
720
745
|
const actions = voice.inputActions
|
|
721
746
|
if (actions && typeof actions.focus === 'function') {
|
|
722
|
-
try { actions.focus(); return } catch {
|
|
747
|
+
try { actions.focus(); return } catch { }
|
|
723
748
|
}
|
|
724
749
|
try {
|
|
725
750
|
const el = document.querySelector('.conversation-input textarea, .cb-composer textarea, .dsh-composer textarea, [data-slate-editor="true"], textarea')
|
|
726
751
|
if (el && typeof el.focus === 'function') el.focus()
|
|
727
|
-
} catch {
|
|
752
|
+
} catch { }
|
|
728
753
|
}
|
|
729
754
|
function blobToBase64(blob) {
|
|
730
755
|
return new Promise((resolve, reject) => {
|
|
@@ -818,7 +843,7 @@ throw e
|
|
|
818
843
|
if (timer) clearTimeout(timer)
|
|
819
844
|
}
|
|
820
845
|
let parsed = null
|
|
821
|
-
try { parsed = await res.json() } catch (e) {
|
|
846
|
+
try { parsed = await res.json() } catch (e) { }
|
|
822
847
|
if (!res.ok || !parsed || !parsed.ok) {
|
|
823
848
|
throw new Error((parsed && parsed.error && parsed.error.message) || `HTTP ${res.status}`)
|
|
824
849
|
}
|
|
@@ -992,7 +1017,7 @@ return insertDraftText(clean, target)
|
|
|
992
1017
|
function announceVoice(phase) {
|
|
993
1018
|
try {
|
|
994
1019
|
window.dispatchEvent(new CustomEvent('dsh-voice:speaking', { detail: { phase } }))
|
|
995
|
-
} catch (noEvents) {
|
|
1020
|
+
} catch (noEvents) { }
|
|
996
1021
|
if (voice.settings.beep) playBeep(phase === 'start' ? 880 : 660)
|
|
997
1022
|
}
|
|
998
1023
|
function playBeep(freq) {
|
|
@@ -1009,8 +1034,8 @@ gain.gain.setValueAtTime(0.12, ac.currentTime)
|
|
|
1009
1034
|
gain.gain.exponentialRampToValueAtTime(0.001, ac.currentTime + 0.09)
|
|
1010
1035
|
osc.connect(gain); gain.connect(ac.destination)
|
|
1011
1036
|
osc.start(); osc.stop(ac.currentTime + 0.1)
|
|
1012
|
-
osc.onended = () => { try { ac.close() } catch (e) {
|
|
1013
|
-
} catch (noAudio) {
|
|
1037
|
+
osc.onended = () => { try { ac.close() } catch (e) { } }
|
|
1038
|
+
} catch (noAudio) { }
|
|
1014
1039
|
}
|
|
1015
1040
|
function speechRecognitionCtor() {
|
|
1016
1041
|
if (typeof window === 'undefined') return null
|
|
@@ -1033,10 +1058,6 @@ return navigator.language
|
|
|
1033
1058
|
}
|
|
1034
1059
|
return 'en-US'
|
|
1035
1060
|
}
|
|
1036
|
-
/**
|
|
1037
|
-
* @param options {{lang: string, continuous: boolean, onInterim, onFinal, onError}}
|
|
1038
|
-
* @returns {{stop: Function, abort: Function}}
|
|
1039
|
-
*/
|
|
1040
1061
|
function startBrowserRecognition(options) {
|
|
1041
1062
|
const Ctor = speechRecognitionCtor()
|
|
1042
1063
|
const recognition = new Ctor()
|
|
@@ -1070,7 +1091,7 @@ if (stopped) {
|
|
|
1070
1091
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1071
1092
|
return
|
|
1072
1093
|
}
|
|
1073
|
-
try { recognition.start() } catch (alreadyRunning) {
|
|
1094
|
+
try { recognition.start() } catch (alreadyRunning) { }
|
|
1074
1095
|
}
|
|
1075
1096
|
try { recognition.start() } catch (cannotStart) {
|
|
1076
1097
|
options.onError(String(cannotStart && cannotStart.message || cannotStart))
|
|
@@ -1089,7 +1110,7 @@ return stopPromise
|
|
|
1089
1110
|
abort() {
|
|
1090
1111
|
stopped = true
|
|
1091
1112
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1092
|
-
try { recognition.abort() } catch (already) {
|
|
1113
|
+
try { recognition.abort() } catch (already) { }
|
|
1093
1114
|
},
|
|
1094
1115
|
}
|
|
1095
1116
|
}
|
|
@@ -1362,11 +1383,11 @@ modelMap,
|
|
|
1362
1383
|
function teardown(rec) {
|
|
1363
1384
|
if (!rec) return
|
|
1364
1385
|
if (rec.wsStream) { try { rec.wsStream.close() } catch (_) {} rec.wsStream = null }
|
|
1365
|
-
try { rec.stream.getTracks().forEach((t) => t.stop()) } catch (e) {
|
|
1366
|
-
if (rec.srcNode) { try { rec.srcNode.disconnect() } catch (e) {
|
|
1367
|
-
if (rec.filterNode) { try { rec.filterNode.disconnect() } catch (e) {
|
|
1368
|
-
if (rec.analyser) { try { rec.analyser.disconnect() } catch (e) {
|
|
1369
|
-
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) { } }
|
|
1370
1391
|
}
|
|
1371
1392
|
voice.teardownRec = teardown
|
|
1372
1393
|
function waitStop(recorder) {
|
|
@@ -1419,7 +1440,7 @@ filter.Q.value = 0.707
|
|
|
1419
1440
|
src.connect(filter)
|
|
1420
1441
|
lastNode = filter
|
|
1421
1442
|
rec.filterNode = filter
|
|
1422
|
-
} catch (e) {
|
|
1443
|
+
} catch (e) { }
|
|
1423
1444
|
rec.analyser = rec.audioCtx.createAnalyser()
|
|
1424
1445
|
rec.analyser.fftSize = 128
|
|
1425
1446
|
lastNode.connect(rec.analyser)
|
|
@@ -1528,7 +1549,7 @@ rec.streamMs = 0
|
|
|
1528
1549
|
if (!rec.closing && !rec.cancelled) {
|
|
1529
1550
|
try {
|
|
1530
1551
|
if (rec.recorder && rec.recorder.state === 'inactive') rec.recorder.start()
|
|
1531
|
-
} catch (e) {
|
|
1552
|
+
} catch (e) { }
|
|
1532
1553
|
}
|
|
1533
1554
|
rec.cutting = false
|
|
1534
1555
|
if (rec.cancelled || blob.size < 600) return // cancelled or too short — not speech
|
|
@@ -1552,7 +1573,8 @@ if (promptInfo && submitToStructuredPrompt(text, promptInfo)) {
|
|
|
1552
1573
|
return
|
|
1553
1574
|
}
|
|
1554
1575
|
}
|
|
1555
|
-
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 })
|
|
1556
1578
|
executeVoiceAction(action, text, target)
|
|
1557
1579
|
return
|
|
1558
1580
|
}
|
|
@@ -1669,6 +1691,7 @@ return
|
|
|
1669
1691
|
}
|
|
1670
1692
|
}
|
|
1671
1693
|
announceVoice('start')
|
|
1694
|
+
playAudioCue('start', { enabled: voice.settings?.audioFeedback !== false })
|
|
1672
1695
|
dictationQueue = Promise.resolve()
|
|
1673
1696
|
voice.set({ phase: 'recording', mode, error: '', levels: [], caption: '', interimTranscript: '' })
|
|
1674
1697
|
modeChain(mode).then((info) => {
|
|
@@ -1697,6 +1720,7 @@ voice.set({ phase: 'error', error: String(err && err.message ? err.message : err
|
|
|
1697
1720
|
function startDictation() { startRecording('dictation') }
|
|
1698
1721
|
function startMessage() { startRecording('message') }
|
|
1699
1722
|
function cancelCurrent() {
|
|
1723
|
+
playAudioCue('stop', { enabled: voice.settings?.audioFeedback !== false })
|
|
1700
1724
|
voice.activeOpId = (voice.activeOpId || 0) + 1
|
|
1701
1725
|
announceVoice('end')
|
|
1702
1726
|
focusComposer()
|
|
@@ -1715,10 +1739,11 @@ rec.closing = true
|
|
|
1715
1739
|
const stopped = waitStop(rec.recorder)
|
|
1716
1740
|
try {
|
|
1717
1741
|
if (rec.recorder && rec.recorder.state !== 'inactive') rec.recorder.stop()
|
|
1718
|
-
} catch (e) {
|
|
1742
|
+
} catch (e) { }
|
|
1719
1743
|
stopped.then(() => { teardown(rec); voice.rec = null; voice.set({ phase: 'idle', error: '' }) })
|
|
1720
1744
|
}
|
|
1721
1745
|
function stopCurrent() {
|
|
1746
|
+
playAudioCue('stop', { enabled: voice.settings?.audioFeedback !== false })
|
|
1722
1747
|
announceVoice('end')
|
|
1723
1748
|
focusComposer()
|
|
1724
1749
|
if (voice.browser) {
|
|
@@ -1761,7 +1786,7 @@ const mode = rec.mode
|
|
|
1761
1786
|
const stopped = waitStop(rec.recorder)
|
|
1762
1787
|
try {
|
|
1763
1788
|
if (rec.recorder && rec.recorder.state !== 'inactive') rec.recorder.stop()
|
|
1764
|
-
} catch (e) {
|
|
1789
|
+
} catch (e) { }
|
|
1765
1790
|
stopped.then(async () => {
|
|
1766
1791
|
if (voice.disposed || rec.cancelled || voice.activeOpId !== opId) {
|
|
1767
1792
|
teardown(rec)
|
|
@@ -1807,7 +1832,7 @@ voice.set({ phase: 'idle' })
|
|
|
1807
1832
|
return
|
|
1808
1833
|
}
|
|
1809
1834
|
}
|
|
1810
|
-
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') {
|
|
1811
1836
|
executeVoiceAction(action, text, target)
|
|
1812
1837
|
return
|
|
1813
1838
|
}
|
|
@@ -1849,41 +1874,6 @@ await processTail()
|
|
|
1849
1874
|
}
|
|
1850
1875
|
})
|
|
1851
1876
|
}
|
|
1852
|
-
function clearDraft(target) {
|
|
1853
|
-
const activeTarget = target || voice._activeTarget
|
|
1854
|
-
const actions = (activeTarget && activeTarget.actions) || voice.inputActions
|
|
1855
|
-
if (actions && typeof actions.setDraft === 'function') actions.setDraft('')
|
|
1856
|
-
}
|
|
1857
|
-
function executeVoiceAction(action, rawText, target) {
|
|
1858
|
-
const activeTarget = target || voice._activeTarget
|
|
1859
|
-
const actions = (activeTarget && activeTarget.actions) || voice.inputActions
|
|
1860
|
-
if (action === 'send') {
|
|
1861
|
-
const text = rawText.replace(/(^|[\s,.!?])(отправь|пошли|send)([\s,.!?]|$)/gi, '').trim()
|
|
1862
|
-
if (text) appendDraft(text, activeTarget)
|
|
1863
|
-
if (typeof actions?.submit === 'function') {
|
|
1864
|
-
actions.submit()
|
|
1865
|
-
}
|
|
1866
|
-
voice.set({ phase: 'idle' })
|
|
1867
|
-
} else if (action === 'clear') {
|
|
1868
|
-
clearDraft(activeTarget)
|
|
1869
|
-
voice.set({ phase: 'idle' })
|
|
1870
|
-
} else if (action === 'newline') {
|
|
1871
|
-
const payload = (rawText.replace(/(^|[\s,.!?])(с новой строки|новая строка|абзац|new line|paragraph)([\s,.!?]|$)/gi, '').trim())
|
|
1872
|
-
appendDraft(payload, activeTarget)
|
|
1873
|
-
voice.set({ phase: 'idle' })
|
|
1874
|
-
} else if (action === 'undo_chunk') {
|
|
1875
|
-
undoLastInsert().then((msg) => {
|
|
1876
|
-
voice.lastUndoNotice = msg
|
|
1877
|
-
voice.notify()
|
|
1878
|
-
setTimeout(() => {
|
|
1879
|
-
if (voice.lastUndoNotice === msg) {
|
|
1880
|
-
voice.lastUndoNotice = ''
|
|
1881
|
-
voice.notify()
|
|
1882
|
-
}
|
|
1883
|
-
}, 3500)
|
|
1884
|
-
})
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
1877
|
function submitPending() {
|
|
1888
1878
|
submitPendingPreview(voice)
|
|
1889
1879
|
}
|
|
@@ -1894,7 +1884,7 @@ function runSessionCommand(cmd) {
|
|
|
1894
1884
|
if (cmd === 'send') submitPending()
|
|
1895
1885
|
else if (cmd === 'cancel') cancelCurrent()
|
|
1896
1886
|
else if (cmd === 'stop') cancelCurrent()
|
|
1897
|
-
else if (cmd === 'continue') {
|
|
1887
|
+
else if (cmd === 'continue') { }
|
|
1898
1888
|
else if (cmd === 'undo_chunk') { executeVoiceAction('undo_chunk') }
|
|
1899
1889
|
}
|
|
1900
1890
|
function keepPending() {
|
|
@@ -2018,7 +2008,12 @@ const HOLD_THRESHOLD_MS = 350
|
|
|
2018
2008
|
const hold = { active: false, mode: null, startedAt: 0, armed: false }
|
|
2019
2009
|
let activePointerCleanup = null
|
|
2020
2010
|
function beginHold(mode, pointerEvent) {
|
|
2021
|
-
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
|
+
}
|
|
2022
2017
|
hold.armed = true
|
|
2023
2018
|
hold.mode = mode
|
|
2024
2019
|
hold.startedAt = Date.now()
|
|
@@ -2051,20 +2046,24 @@ voice.notify()
|
|
|
2051
2046
|
function endHold(cancelled) {
|
|
2052
2047
|
if (activePointerCleanup) { try { activePointerCleanup() } catch (e) {} }
|
|
2053
2048
|
if (!hold.armed) return
|
|
2049
|
+
const wasHeld = hold.active
|
|
2054
2050
|
hold.armed = false
|
|
2055
2051
|
voice.holding = false
|
|
2056
2052
|
voice.notify()
|
|
2057
|
-
if (cancelled)
|
|
2058
|
-
|
|
2053
|
+
if (cancelled) {
|
|
2054
|
+
cancelCurrent()
|
|
2055
|
+
} else if (wasHeld) {
|
|
2056
|
+
stopCurrent()
|
|
2057
|
+
}
|
|
2059
2058
|
}
|
|
2060
2059
|
let activeHotkeyCleanup = null
|
|
2061
2060
|
function clearGlobalHotkey() {
|
|
2062
2061
|
if (typeof activeHotkeyCleanup === 'function') {
|
|
2063
|
-
try { activeHotkeyCleanup() } catch (_) {
|
|
2062
|
+
try { activeHotkeyCleanup() } catch (_) { }
|
|
2064
2063
|
activeHotkeyCleanup = null
|
|
2065
2064
|
}
|
|
2066
2065
|
if (typeof window !== 'undefined' && typeof window.__dsh_voice_hotkey_cleanup === 'function') {
|
|
2067
|
-
try { window.__dsh_voice_hotkey_cleanup() } catch (_) {
|
|
2066
|
+
try { window.__dsh_voice_hotkey_cleanup() } catch (_) { }
|
|
2068
2067
|
window.__dsh_voice_hotkey_cleanup = null
|
|
2069
2068
|
}
|
|
2070
2069
|
}
|
|
@@ -2352,6 +2351,47 @@ p.sessionMismatch
|
|
|
2352
2351
|
: null,
|
|
2353
2352
|
)
|
|
2354
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
|
+
}
|
|
2355
2395
|
const DICTATION_MODES = ['clean', 'task', 'note', 'verbatim']
|
|
2356
2396
|
function getDictationModeLabel(m, t) {
|
|
2357
2397
|
const trans = t || moduleT
|
|
@@ -2381,7 +2421,7 @@ if (pick) {
|
|
|
2381
2421
|
_accentColorCache = { color: pick, expires: now + 1000 }
|
|
2382
2422
|
return pick
|
|
2383
2423
|
}
|
|
2384
|
-
} catch (noTheme) {
|
|
2424
|
+
} catch (noTheme) { }
|
|
2385
2425
|
return fallback || voice.waveColor || 'currentColor'
|
|
2386
2426
|
}
|
|
2387
2427
|
function softColor(fallback) {
|
|
@@ -2395,7 +2435,7 @@ if (pick) {
|
|
|
2395
2435
|
_softColorCache = { color: pick, expires: now + 1000 }
|
|
2396
2436
|
return pick
|
|
2397
2437
|
}
|
|
2398
|
-
} catch (noTheme) {
|
|
2438
|
+
} catch (noTheme) { }
|
|
2399
2439
|
return fallback || voice.waveColor || 'currentColor'
|
|
2400
2440
|
}
|
|
2401
2441
|
function drawLiquidWave(g, w, h, levels, color, time) {
|
|
@@ -2875,7 +2915,7 @@ liveInterimPreview: data && data.liveInterimPreview !== false,
|
|
|
2875
2915
|
structuredPromptVoice: data && data.structuredPromptVoice !== false,
|
|
2876
2916
|
})
|
|
2877
2917
|
})
|
|
2878
|
-
.catch(() => {
|
|
2918
|
+
.catch(() => { })
|
|
2879
2919
|
}
|
|
2880
2920
|
reload()
|
|
2881
2921
|
window.addEventListener('dsh-voice:settings-saved', reload)
|
|
@@ -3753,8 +3793,8 @@ const toggleTestMic = async () => {
|
|
|
3753
3793
|
if (testingMic) {
|
|
3754
3794
|
if (testRef.current) {
|
|
3755
3795
|
testRef.current.active = false
|
|
3756
|
-
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) {
|
|
3757
|
-
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) { } }
|
|
3758
3798
|
testRef.current = null
|
|
3759
3799
|
}
|
|
3760
3800
|
setTestingMic(false)
|
|
@@ -3779,7 +3819,7 @@ filter.frequency.value = 80
|
|
|
3779
3819
|
filter.Q.value = 0.707
|
|
3780
3820
|
src.connect(filter)
|
|
3781
3821
|
lastNode = filter
|
|
3782
|
-
} catch (e) {
|
|
3822
|
+
} catch (e) { }
|
|
3783
3823
|
const analyser = audioCtx.createAnalyser()
|
|
3784
3824
|
analyser.fftSize = 128
|
|
3785
3825
|
lastNode.connect(analyser)
|
|
@@ -3804,8 +3844,8 @@ React.useEffect(() => {
|
|
|
3804
3844
|
return () => {
|
|
3805
3845
|
if (testRef.current) {
|
|
3806
3846
|
testRef.current.active = false
|
|
3807
|
-
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) {
|
|
3808
|
-
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) { } }
|
|
3809
3849
|
testRef.current = null
|
|
3810
3850
|
}
|
|
3811
3851
|
}
|
|
@@ -4219,13 +4259,13 @@ ctx.configForms.describe().load()
|
|
|
4219
4259
|
} else if (ctx.settingsScope && typeof ctx.settingsScope.describe === 'function') {
|
|
4220
4260
|
ctx.settingsScope.describe().load()
|
|
4221
4261
|
}
|
|
4222
|
-
} catch (e) {
|
|
4262
|
+
} catch (e) { }
|
|
4223
4263
|
}, 1000)
|
|
4224
4264
|
return () => clearInterval(timer)
|
|
4225
4265
|
}, [ready])
|
|
4226
4266
|
const deepClone = (obj) => {
|
|
4227
4267
|
if (typeof structuredClone === 'function') {
|
|
4228
|
-
try { return structuredClone(obj) } catch (e) {
|
|
4268
|
+
try { return structuredClone(obj) } catch (e) { }
|
|
4229
4269
|
}
|
|
4230
4270
|
try { return JSON.parse(JSON.stringify(obj)) } catch (e) { return Object.assign({}, obj) }
|
|
4231
4271
|
}
|
|
@@ -4289,6 +4329,7 @@ autoSendVisualRing: val.autoSendVisualRing !== false,
|
|
|
4289
4329
|
voiceActions: val.voiceActions !== false,
|
|
4290
4330
|
techJargonCorrection: val.techJargonCorrection !== false,
|
|
4291
4331
|
liveInterimPreview: val.liveInterimPreview !== false,
|
|
4332
|
+
audioFeedback: val.audioFeedback !== false,
|
|
4292
4333
|
structuredPromptVoice: val.structuredPromptVoice !== false,
|
|
4293
4334
|
dictationMode: val.dictationMode || 'clean',
|
|
4294
4335
|
dictationPrompts: val.dictationPrompts || {},
|
|
@@ -4366,7 +4407,6 @@ for (const k of Object.keys(draft)) {
|
|
|
4366
4407
|
try {
|
|
4367
4408
|
await scope.set(k, draft[k])
|
|
4368
4409
|
} catch (e) {
|
|
4369
|
-
/* best effort on loopback */
|
|
4370
4410
|
}
|
|
4371
4411
|
}
|
|
4372
4412
|
}
|
|
@@ -4402,9 +4442,10 @@ autoSendVisualRing: d.autoSendVisualRing !== false,
|
|
|
4402
4442
|
voiceActions: d.voiceActions !== false,
|
|
4403
4443
|
techJargonCorrection: d.techJargonCorrection !== false,
|
|
4404
4444
|
liveInterimPreview: d.liveInterimPreview !== false,
|
|
4445
|
+
audioFeedback: d.audioFeedback !== false,
|
|
4405
4446
|
structuredPromptVoice: d.structuredPromptVoice !== false,
|
|
4406
4447
|
})
|
|
4407
|
-
try { window.dispatchEvent(new CustomEvent('dsh-voice:settings-saved')) } catch (noEvents) {
|
|
4448
|
+
try { window.dispatchEvent(new CustomEvent('dsh-voice:settings-saved')) } catch (noEvents) { }
|
|
4408
4449
|
setSaved(true); setJargonInput(null)
|
|
4409
4450
|
setTimeout(() => setSaved(false), 2000)
|
|
4410
4451
|
fetchStatus()
|
|
@@ -4646,6 +4687,15 @@ onChange: (e) => setTop('structuredPromptVoice', e.target.checked),
|
|
|
4646
4687
|
}),
|
|
4647
4688
|
t('structuredPromptVoice'),
|
|
4648
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
|
+
),
|
|
4649
4699
|
),
|
|
4650
4700
|
),
|
|
4651
4701
|
h(DictationModesSection, {
|
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
|
}
|
package/lib/schema.js
CHANGED
|
@@ -168,6 +168,8 @@ 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
175
|
dictationMode: z.union(['verbatim', 'clean', 'task', 'note', 'bug']).default('clean')
|
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
|
/**
|
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",
|