@goodandready/dsh-voice 0.9.52 → 0.9.54
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 +230 -206
- package/lib/host-routes.js +4 -0
- package/lib/normalize.js +30 -2
- package/lib/schema.js +8 -0
- package/lib/transcribe-core.js +4 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -18,39 +18,39 @@ 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
|
|
53
|
-
'pauseHint':'
|
|
52
|
+
'dictationHint':'Speech is chunked at pauses into the input.', 'pauseMs':'Pause that ends a phrase, ms',
|
|
53
|
+
'pauseHint':'Pause duration that triggers phrase cut', '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',
|
|
56
56
|
'lowVolumeHint':'Speak louder', 'vadEngine':'VAD engine', 'vadEngineHint':'Neural Silero VAD (WASM/ONNX) or classic amplitude gate',
|
|
@@ -62,15 +62,15 @@ const en = {
|
|
|
62
62
|
'polishHint':'Fix punctuation and fillers via the harness model before inserting', 'stream':'Continuous dictation',
|
|
63
63
|
'streamHint':'Cut phrases by a timer while you speak instead of waiting for a long pause', 'streamChunkMs':'Stream chunk (ms)',
|
|
64
64
|
'vadAdapt':'Adaptive silence', 'vadAdaptHint':'Auto-tune the silence threshold to the pace of your speech. 0 = fixed',
|
|
65
|
-
'wakeWord':'Wake word', 'wakeWordHint':'
|
|
65
|
+
'wakeWord':'Wake word', 'wakeWordHint':'Starts recording when speech begins with phrase. Empty = off',
|
|
66
66
|
'bargeIn':'Barge-in', 'polishSend':'Polish whole draft before sending',
|
|
67
67
|
'polishSendHint':'Run the composed draft through the model right before sending', 'editablePreview':'Editable preview before send',
|
|
68
|
-
'editablePreviewHint':'
|
|
68
|
+
'editablePreviewHint':'Preview text before sending with editing 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
|
-
'polishBaseUrlHint':'OpenAI
|
|
73
|
+
'polishBaseUrlHint':'OpenAI /chat/completions URL. Empty = harness model',
|
|
74
74
|
'polishModel':'Offline polish model', 'polishKeyEnv':'Offline polish key credential',
|
|
75
75
|
'voiceCommandsLabel':'Voice edit commands ("new line", "paragraph")',
|
|
76
76
|
'normalizeTranscriptHint':'transcribe_audio: spoken numbers to digits, tidy punctuation', 'messageTitle':'Voice message',
|
|
@@ -79,19 +79,19 @@ 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
|
-
'calibrateNoiseHint':'
|
|
88
|
+
'calibrateNoiseHint':'Measures room noise for 2s to calibrate noise gate', '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',
|
|
94
|
-
'contextGlossaryHint':'
|
|
94
|
+
'contextGlossaryHint':'Extract identifiers from composer to improve STT',
|
|
95
95
|
'providerDashboard':'Provider Latency & Health', 'avgLatency':'Avg latency', 'successRate':'Success', 'fast':'Fast', 'normal':'Normal',
|
|
96
96
|
'slow':'Slow', 'error':'Error', 'idle':'No calls', 'play':'Play', 'pause':'Pause', 'listenBack':'Listen back',
|
|
97
97
|
'lastRecording':'Last voice note', 'sensevoiceHint':'SenseVoice-ONNX / Sherpa-ONNX · ultra-fast local STT (~50ms)',
|
|
@@ -113,36 +113,37 @@ 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':'Prevents assistant audio feedback into mic.',
|
|
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
|
+
'showDictationModeBtn':'Dictation mode button', 'showDictationBtn':'Voice typing button', 'showMessageBtn':'Voice message button',
|
|
128
129
|
'autoSendVisualRing':'Silence Ring countdown animation',
|
|
129
130
|
'voiceActionsLabel':'Voice action commands ("send", "cancel", "clear", "new line")',
|
|
130
131
|
'liveInterimPreview':'Live speech preview (ghost text preview)',
|
|
131
132
|
'structuredPromptVoice':'Spoken answers for interactive choice prompts', 'modeVerbatim':'Verbatim', 'modeClean':'Clean Text',
|
|
132
133
|
'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':'
|
|
134
|
+
'dictationModeDesc':'Dictation post-processing: Verbatim (no LLM), Clean (punct & fillers), Agent task, or Note.',
|
|
134
135
|
'dictationPromptsTitle':'Dictation Prompt Templates',
|
|
135
|
-
'dictationPromptsDesc':'Custom
|
|
136
|
+
'dictationPromptsDesc':'Custom templates for dictation modes. Use {text} as speech placeholder.',
|
|
136
137
|
'promptClean':'Clean text prompt', 'promptTask':'Agent task prompt', 'promptNote':'Note prompt', 'resetPrompts':'Reset to defaults',
|
|
137
|
-
'voiceMacrosTitle':'Voice
|
|
138
|
-
'voiceMacrosDesc':'Spoken
|
|
138
|
+
'voiceMacrosTitle':'Voice Macros',
|
|
139
|
+
'voiceMacrosDesc':'Spoken triggers expanded into prompt templates.', 'addMacro':'Add macro',
|
|
139
140
|
'macroTrigger':'Spoken trigger phrase', 'macroTemplate':'Expanded prompt template', 'macroDelete':'Delete', 'rawTab':'Raw STT',
|
|
140
141
|
'resultTab':'Result', 'llmUnavailableFallback':'LLM unavailable, showing raw transcript', 'jargonTitle':'Developer Lexicon & IT Jargon',
|
|
141
142
|
'techJargonCorrection':'Auto-correct technical jargon (GitHub, Docker, pnpm, Kubernetes, etc.)', 'jargonAdd':'Add replacement',
|
|
142
143
|
'jargonFrom':'Spoken slang', 'jargonTo':'Correct spelling', 'jargonPlaceholder':'k8s -> kubernetes\npr -> pull request',
|
|
143
144
|
'voiceInput':'Voice input', 'assistantSpeakingGated':'Assistant speaking (gated mode)', 'jargonFormatHint':' (spoken -> replacement)',
|
|
144
145
|
'errorPrefix':'Error', 'wizardTitle':'First-Run Setup & Diagnostics Wizard',
|
|
145
|
-
'wizardDesc':'
|
|
146
|
+
'wizardDesc':'Diagnostics: check HTTPS/context, microphone access, audio level, and STT round-trip.',
|
|
146
147
|
'wizardBtnLaunch':'Launch Mic & STT Wizard', 'wizardClose':'Close Wizard', 'wizardStep1':'1. Audio & Environment',
|
|
147
148
|
'wizardStep2':'2. Live Signal Test', 'wizardStep3':'3. STT Transcription Test',
|
|
148
149
|
'wizardSecureContextOk':'Secure context / HTTPS verified', 'wizardSecureContextBad':'Insecure context (HTTPS or localhost required)',
|
|
@@ -158,39 +159,39 @@ const en = {
|
|
|
158
159
|
'wizardAreaServer':'Local MiniPC server (SenseVoice / Whisper)', 'wizardAreaCloud':'Remote cloud provider',
|
|
159
160
|
'wizardStartTestRecord':'Record 3-Second Test Phrase', 'wizardRecordingTest':'Recording test phrase… speak now ({left}s)',
|
|
160
161
|
'wizardTranscribingTest':'Transcribing test phrase…', 'wizardTestResult':'STT Test Result:',
|
|
161
|
-
'wizardTestSuccess':'STT
|
|
162
|
-
'wizardTestEmpty':'No speech detected
|
|
162
|
+
'wizardTestSuccess':'STT verified! Latency: {latency}ms',
|
|
163
|
+
'wizardTestEmpty':'No speech detected. Please speak clearly and retry.',
|
|
163
164
|
'wizardTestFailed':'STT test failed: {error}', 'wizardNextStepHint':'Next step: {hint}',
|
|
164
165
|
'wizardHintPermission':'Click "Request Microphone Access" and allow browser permission prompt.',
|
|
165
166
|
'wizardHintDevice':'Check microphone connection or select a different input device.',
|
|
166
167
|
'wizardHintHttps':'Open DeepSeek Harness via HTTPS or localhost address.',
|
|
167
168
|
'wizardHintProvider':'Configure STT engine credentials or install SenseVoice model below.',
|
|
168
|
-
'wizardHintWinDesktop':'
|
|
169
|
-
'wizardHintWinBrowser':'
|
|
170
|
-
'wizardHintMacDesktop':'
|
|
169
|
+
'wizardHintWinDesktop':'Windows Settings → Microphone: enable desktop access.',
|
|
170
|
+
'wizardHintWinBrowser':'Allow microphone access in browser address bar.',
|
|
171
|
+
'wizardHintMacDesktop':'macOS Settings → Microphone: enable DSH.',
|
|
171
172
|
'wizardOpenWinMicSettings':'Open Windows Mic Settings', 'wizardFinishSuccess':'Setup & Verification Complete',
|
|
172
|
-
'wizardSkip':'Skip Wizard', 'wizardStatusCompleted':'
|
|
173
|
+
'wizardSkip':'Skip Wizard', 'wizardStatusCompleted':'Mic & STT verified', 'exportDiagnosticsBtn':'Export Diagnostics',
|
|
173
174
|
'exportingDiagnostics':'Exporting report…', 'diagnosticsExportSuccess':'Report downloaded',
|
|
174
|
-
'recentRecognitionsTitle':'Recent
|
|
175
|
+
'recentRecognitionsTitle':'Recent Recognitions', 'noRecognitionsYet':'No recent recognition records yet.',
|
|
175
176
|
'diagLatencyBreakdown':'Latency breakdown:', 'diagVad':'VAD: {ms}ms', 'diagStt':'STT: {ms}ms', 'diagPolish':'Polish: {ms}ms',
|
|
176
177
|
'diagTotal':'Total: {ms}ms', 'diagBytes':'Audio: {bytes} B', 'diagWords':'Words: {count}',
|
|
177
|
-
'diagExportNotice':'Exported JSON contains anonymized timings
|
|
178
|
+
'diagExportNotice':'Exported JSON contains anonymized timings and error codes.',
|
|
178
179
|
'hostOnline':'Host online', 'hostOffline':'Host unreachable', 'whisperReady':'Whisper ready', 'whisperStopped':'Whisper stopped',
|
|
179
180
|
'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':'
|
|
181
|
+
'noiseGateLow':'-50 dB (Low)', 'noiseGateStandard':'-45 dB (Default)', 'noiseGateMedium':'-35 dB (Medium)',
|
|
182
|
+
'noiseGateHigh':'-25 dB (High)', 'npuCpu':'CPU (Standard)',
|
|
183
|
+
'installModelSensevoice':'SenseVoice-Small (150MB)', 'installModelWhisperTurbo':'Whisper Large-v3-Turbo (800MB)',
|
|
184
|
+
'promptCleanPlaceholder':'Punctuation & filler cleanup',
|
|
185
|
+
'promptTaskPlaceholder':'Structured task format',
|
|
186
|
+
'promptNotePlaceholder':'Key points & action items', 'settingsConflict':'Settings conflict: parallel changes detected',
|
|
186
187
|
'saveFailedFallback':'Save failed', 'benchmarkFailed':'Benchmark failed', 'networkError':'Network error', 'benchmarkOffline':'Offline',
|
|
187
188
|
'benchmarkCores':'Cores', 'benchmarkCoresUnit':'cores', 'benchRatingUltraFast':'Ultra-fast', 'benchRatingRealtime':'Real-time',
|
|
188
|
-
'msShort':'ms', 'transcriptionTimeout':'Transcription
|
|
189
|
+
'msShort':'ms', 'transcriptionTimeout':'Transcription timed out', 'audioContextUnsupported':'AudioContext not supported',
|
|
189
190
|
'audioReadFailed':'failed to read audio', 'fileReaderUnsupported':'FileReader not supported',
|
|
190
|
-
'benchmarkNoAsrServer':'Local ASR
|
|
191
|
+
'benchmarkNoAsrServer':'Local ASR offline. Hardware detected.',
|
|
191
192
|
}
|
|
192
193
|
const zh = {
|
|
193
|
-
'saveFailed':'部分字段未保存 —', 'cardHint':'
|
|
194
|
+
'saveFailed':'部分字段未保存 —', 'cardHint':'听写与语音输入设置', 'expand':'展开', 'collapse':'收起', 'composerUnavailable':'输入框不可用',
|
|
194
195
|
'keySpace':'空格', 'keyUnset':'未设置', 'recognitionError':'识别失败', 'micUnavailable':'麦克风不可用:需要 HTTPS 或 localhost',
|
|
195
196
|
'noRecorder':'当前浏览器不支持 MediaRecorder', 'browserFailed':'浏览器未能识别:', 'nothingHeard':'未识别到任何内容', 'dictationBtn':'语音输入',
|
|
196
197
|
'messageBtn':'语音消息 — 点击或按住', 'dictationPill':'听写 — 文本将追加至输入框', 'messagePill':'正在录制语音消息', 'cancel':'取消', 'holdHint':'按住录音 — 松开即发送',
|
|
@@ -198,7 +199,7 @@ const zh = {
|
|
|
198
199
|
'hide':'隐藏', 'title':'语音', 'recordSlot':'语音录制', 'browserHint':'Web Speech 语音识别 (设为 auto 时使用页面或浏览器语言,Chrome 会上传音频至 Google)',
|
|
199
200
|
'browserWebGpu':'浏览器 WebGPU Whisper (离线)', 'browserWebGpuHint':'通过 WebGPU/WASM 在浏览器本地运行 Whisper 模型:完全离线,音频无需上传到主机。',
|
|
200
201
|
'npuProvider':'硬件加速 (SBC NPU / 主机)',
|
|
201
|
-
'npuProviderHint':'SenseVoice
|
|
202
|
+
'npuProviderHint':'SenseVoice 加速引擎:CPU、Rockchip NPU、OpenVINO 或 CUDA。', 'npuThreads':'计算线程 (CPU/SBC)',
|
|
202
203
|
'benchmarkTitle':'硬件基准测试 (速度与延迟)', 'runBenchmarkBtn':'运行基准测试', 'benchmarking':'正在运行测试…',
|
|
203
204
|
'benchmarkHint':'测试当前执行提供者在 1.0 秒音频下的实时率 (RTF) 与推理延迟。', 'webgpuStatus':'浏览器 WebGPU 状态', 'webgpuAvailable':'WebGPU 可用 (硬件加速就绪)',
|
|
204
205
|
'webgpuNotAvailable':'未检测到 WebGPU (将自动回退到服务端)', 'openaiHint':'whisper-1 · 密钥 OPENAI_API_KEY',
|
|
@@ -255,10 +256,11 @@ const zh = {
|
|
|
255
256
|
'sensevoiceDesc':'CPU 上超低延迟离线语音识别 (50–100ms,中英俄多语种)。', 'installSensevoice':'一键安装 SenseVoice-Small',
|
|
256
257
|
'installingSensevoice':'正在安装 SenseVoice…', 'sensevoiceReady':'已就绪', 'sensevoiceNotInstalled':'未安装', 'sensevoiceDownloading':'正在下载模型…',
|
|
257
258
|
'turnTakingTitle':'轮流对话与音频协同', 'turnTakingDesc':'协调听与说,避免扬声器播放的声音被麦克风二次拾音。', 'gatedTurnTaking':'门控模式 (助手播报时麦克风自动静音)',
|
|
258
|
-
'bargeInDesc':'实时打断 (说话时立即打断助手朗读)', 'smartActionsTitle':'免提与智能指令', '
|
|
259
|
+
'bargeInDesc':'实时打断 (说话时立即打断助手朗读)', 'smartActionsTitle':'免提与智能指令', 'audioFeedback':'声音提示',
|
|
260
|
+
'showDictationModeBtn':'听写模式按钮', 'showDictationBtn':'语音输入按钮', 'showMessageBtn':'语音消息按钮', 'autoSendVisualRing':'环形倒计时动画指示器',
|
|
259
261
|
'voiceActionsLabel':'语音动作指令 ("发送", "取消", "清空", "换行")', 'liveInterimPreview':'实时语音文本预览 (幽灵文本)', 'structuredPromptVoice':'语音应答交互式选择提示',
|
|
260
262
|
'modeVerbatim':'逐字直录', 'modeClean':'清爽文本', 'modeTask':'智能体任务', 'modeNote':'便签备忘', 'modeBug':'缺陷报告', 'promptBug':'缺陷报告提示词', 'promptBugPlaceholder':'默认:问题概要、异常现象、复现步骤、预期行为', 'dictationModeTitle':'听写后处理模式',
|
|
261
|
-
'dictationModeDesc':'
|
|
263
|
+
'dictationModeDesc':'听写文本后处理:逐字直录(零LLM)、清爽文本、智能体任务或便签。', 'dictationPromptsTitle':'听写提示词模板',
|
|
262
264
|
'dictationPromptsDesc':'自定义听写后处理提示词模板。使用 {text} 作为识别语音的占位符。', 'promptClean':'清爽文本提示词', 'promptTask':'智能体任务提示词', 'promptNote':'便签提示词',
|
|
263
265
|
'resetPrompts':'恢复默认模板', 'voiceMacrosTitle':'语音动作宏', 'voiceMacrosDesc':'语音触发词自动展开为结构化提示词模板。', 'addMacro':'添加动作宏',
|
|
264
266
|
'macroTrigger':'语音触发短语', 'macroTemplate':'展开提示词模板', 'macroDelete':'删除', 'rawTab':'原始识别', 'resultTab':'处理结果',
|
|
@@ -283,7 +285,7 @@ const zh = {
|
|
|
283
285
|
'wizardHintWinDesktop':'系统麦克风被阻止。请在 Windows【设置】→【隐私和安全性】→【麦克风】中开启最下方的【允许桌面应用访问你的麦克风】。',
|
|
284
286
|
'wizardHintWinBrowser':'麦克风权限被拒绝。请在浏览器地址栏允许麦克风权限,或在 Windows【设置】→【隐私和安全性】→【麦克风】中开启访问。',
|
|
285
287
|
'wizardHintMacDesktop':'系统麦克风被阻止。请在 macOS【系统设置】→【隐私与安全性】→【麦克风】中勾选允许 DSH Desktop。', 'wizardOpenWinMicSettings':'打开系统麦克风设置',
|
|
286
|
-
'wizardFinishSuccess':'设置与验证已完成', 'wizardSkip':'跳过向导', 'wizardStatusCompleted':'麦克风与 STT 诊断已就绪', 'exportDiagnosticsBtn':'
|
|
288
|
+
'wizardFinishSuccess':'设置与验证已完成', 'wizardSkip':'跳过向导', 'wizardStatusCompleted':'麦克风与 STT 诊断已就绪', 'exportDiagnosticsBtn':'导出诊断',
|
|
287
289
|
'exportingDiagnostics':'正在导出报告…', 'diagnosticsExportSuccess':'诊断报告已下载', 'recentRecognitionsTitle':'近期识别遥测详情',
|
|
288
290
|
'noRecognitionsYet':'暂无近期识别记录。', 'diagLatencyBreakdown':'耗时分布:', 'diagVad':'VAD:{ms}毫秒', 'diagStt':'STT:{ms}毫秒',
|
|
289
291
|
'diagPolish':'后处理:{ms}毫秒', 'diagTotal':'总耗时:{ms}毫秒', 'diagBytes':'音频大小:{bytes} 字节', 'diagWords':'词数:{count}',
|
|
@@ -301,7 +303,7 @@ const zh = {
|
|
|
301
303
|
let moduleT = (key) => en[key] || key
|
|
302
304
|
const t = (key) => moduleT(key)
|
|
303
305
|
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;
|
|
306
|
+
'.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
307
|
const cssId = 'dsh-voice/client.module.css'
|
|
306
308
|
if (typeof document !== 'undefined' && !document.querySelector('style[data-dsh-plugin="dsh-voice"][data-plugin-css="' + cssId + '"]')) {const tag = document.createElement('style')
|
|
307
309
|
tag.textContent = CSS
|
|
@@ -345,8 +347,33 @@ md: '13px',
|
|
|
345
347
|
lg: '15px',
|
|
346
348
|
},
|
|
347
349
|
}
|
|
350
|
+
let _ac = null
|
|
351
|
+
function playAudioCue(t, { enabled = true } = {}) {
|
|
352
|
+
if (!enabled || typeof window === 'undefined') return
|
|
353
|
+
try {
|
|
354
|
+
const C = window.AudioContext || window.webkitAudioContext
|
|
355
|
+
if (!C) return
|
|
356
|
+
if (!_ac || _ac.state === 'closed') _ac = new C()
|
|
357
|
+
if (_ac.state === 'suspended') _ac.resume().catch(() => {})
|
|
358
|
+
const n = _ac.currentTime, o = _ac.createOscillator(), g = _ac.createGain()
|
|
359
|
+
o.connect(g); g.connect(_ac.destination)
|
|
360
|
+
if (t === 'start') {
|
|
361
|
+
o.frequency.setValueAtTime(440, n); o.frequency.exponentialRampToValueAtTime(880, n + 0.035)
|
|
362
|
+
g.gain.setValueAtTime(0.04, n); g.gain.exponentialRampToValueAtTime(0.001, n + 0.04)
|
|
363
|
+
o.start(n); o.stop(n + 0.045)
|
|
364
|
+
} else if (t === 'stop') {
|
|
365
|
+
o.frequency.setValueAtTime(700, n); o.frequency.exponentialRampToValueAtTime(350, n + 0.035)
|
|
366
|
+
g.gain.setValueAtTime(0.04, n); g.gain.exponentialRampToValueAtTime(0.001, n + 0.04)
|
|
367
|
+
o.start(n); o.stop(n + 0.045)
|
|
368
|
+
} else if (t === 'success') {
|
|
369
|
+
o.type = 'triangle'; o.frequency.setValueAtTime(587.33, n); o.frequency.setValueAtTime(880, n + 0.02)
|
|
370
|
+
g.gain.setValueAtTime(0.035, n); g.gain.exponentialRampToValueAtTime(0.001, n + 0.06)
|
|
371
|
+
o.start(n); o.stop(n + 0.065)
|
|
372
|
+
}
|
|
373
|
+
} catch (_) {}
|
|
374
|
+
}
|
|
348
375
|
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
|
|
376
|
+
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
377
|
function transliterateDevWord(w) {
|
|
351
378
|
const low = String(w || '').toLowerCase()
|
|
352
379
|
return CLIENT_DEV_WORDS[low] || low.split('').map((c) => DEV_TRANSLIT[c] || c).join('')
|
|
@@ -367,7 +394,7 @@ const ws = devWordsOf(str)
|
|
|
367
394
|
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
395
|
return f ? f(ws) : str
|
|
369
396
|
}
|
|
370
|
-
const CLIENT_CASING_TARGETS = '(?:camel
|
|
397
|
+
const CLIENT_CASING_TARGETS = '(?:(?:camel|кэмел|snake|снейк|constant|upper|kebab|кебаб|pascal|паскаль)[-_\\s]*(?:case|кейс|snake)?|констант(?:у|а)?|апер[-_\\s]*снейк)'
|
|
371
398
|
function applyCodeCasing(text) {
|
|
372
399
|
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
400
|
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 +644,9 @@ window.dispatchEvent(new CustomEvent('dsh:tts:cancel', { bubbles: true }))
|
|
|
617
644
|
window.dispatchEvent(new CustomEvent('dsh:tts:stop', { bubbles: true }))
|
|
618
645
|
const audios = document.querySelectorAll('audio')
|
|
619
646
|
for (const a of audios) {
|
|
620
|
-
if (!a.paused) { try { a.pause() } catch (err) {
|
|
647
|
+
if (!a.paused) { try { a.pause() } catch (err) { } }
|
|
621
648
|
}
|
|
622
|
-
} catch {
|
|
649
|
+
} catch { }
|
|
623
650
|
voice.set({ isTtsSpeaking: false })
|
|
624
651
|
}
|
|
625
652
|
function findActiveStructuredPrompt() {
|
|
@@ -631,7 +658,7 @@ const input = modal.querySelector('textarea, input[type="text"]')
|
|
|
631
658
|
const buttons = Array.from(modal.querySelectorAll('button:not([disabled])'))
|
|
632
659
|
return { modal, input, buttons }
|
|
633
660
|
}
|
|
634
|
-
} catch {
|
|
661
|
+
} catch { }
|
|
635
662
|
return null
|
|
636
663
|
}
|
|
637
664
|
function submitToStructuredPrompt(text, promptInfo) {
|
|
@@ -719,12 +746,12 @@ function focusComposer() {
|
|
|
719
746
|
if (typeof window === 'undefined') return
|
|
720
747
|
const actions = voice.inputActions
|
|
721
748
|
if (actions && typeof actions.focus === 'function') {
|
|
722
|
-
try { actions.focus(); return } catch {
|
|
749
|
+
try { actions.focus(); return } catch { }
|
|
723
750
|
}
|
|
724
751
|
try {
|
|
725
752
|
const el = document.querySelector('.conversation-input textarea, .cb-composer textarea, .dsh-composer textarea, [data-slate-editor="true"], textarea')
|
|
726
753
|
if (el && typeof el.focus === 'function') el.focus()
|
|
727
|
-
} catch {
|
|
754
|
+
} catch { }
|
|
728
755
|
}
|
|
729
756
|
function blobToBase64(blob) {
|
|
730
757
|
return new Promise((resolve, reject) => {
|
|
@@ -818,7 +845,7 @@ throw e
|
|
|
818
845
|
if (timer) clearTimeout(timer)
|
|
819
846
|
}
|
|
820
847
|
let parsed = null
|
|
821
|
-
try { parsed = await res.json() } catch (e) {
|
|
848
|
+
try { parsed = await res.json() } catch (e) { }
|
|
822
849
|
if (!res.ok || !parsed || !parsed.ok) {
|
|
823
850
|
throw new Error((parsed && parsed.error && parsed.error.message) || `HTTP ${res.status}`)
|
|
824
851
|
}
|
|
@@ -992,7 +1019,7 @@ return insertDraftText(clean, target)
|
|
|
992
1019
|
function announceVoice(phase) {
|
|
993
1020
|
try {
|
|
994
1021
|
window.dispatchEvent(new CustomEvent('dsh-voice:speaking', { detail: { phase } }))
|
|
995
|
-
} catch (noEvents) {
|
|
1022
|
+
} catch (noEvents) { }
|
|
996
1023
|
if (voice.settings.beep) playBeep(phase === 'start' ? 880 : 660)
|
|
997
1024
|
}
|
|
998
1025
|
function playBeep(freq) {
|
|
@@ -1009,8 +1036,8 @@ gain.gain.setValueAtTime(0.12, ac.currentTime)
|
|
|
1009
1036
|
gain.gain.exponentialRampToValueAtTime(0.001, ac.currentTime + 0.09)
|
|
1010
1037
|
osc.connect(gain); gain.connect(ac.destination)
|
|
1011
1038
|
osc.start(); osc.stop(ac.currentTime + 0.1)
|
|
1012
|
-
osc.onended = () => { try { ac.close() } catch (e) {
|
|
1013
|
-
} catch (noAudio) {
|
|
1039
|
+
osc.onended = () => { try { ac.close() } catch (e) { } }
|
|
1040
|
+
} catch (noAudio) { }
|
|
1014
1041
|
}
|
|
1015
1042
|
function speechRecognitionCtor() {
|
|
1016
1043
|
if (typeof window === 'undefined') return null
|
|
@@ -1033,10 +1060,6 @@ return navigator.language
|
|
|
1033
1060
|
}
|
|
1034
1061
|
return 'en-US'
|
|
1035
1062
|
}
|
|
1036
|
-
/**
|
|
1037
|
-
* @param options {{lang: string, continuous: boolean, onInterim, onFinal, onError}}
|
|
1038
|
-
* @returns {{stop: Function, abort: Function}}
|
|
1039
|
-
*/
|
|
1040
1063
|
function startBrowserRecognition(options) {
|
|
1041
1064
|
const Ctor = speechRecognitionCtor()
|
|
1042
1065
|
const recognition = new Ctor()
|
|
@@ -1070,7 +1093,7 @@ if (stopped) {
|
|
|
1070
1093
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1071
1094
|
return
|
|
1072
1095
|
}
|
|
1073
|
-
try { recognition.start() } catch (alreadyRunning) {
|
|
1096
|
+
try { recognition.start() } catch (alreadyRunning) { }
|
|
1074
1097
|
}
|
|
1075
1098
|
try { recognition.start() } catch (cannotStart) {
|
|
1076
1099
|
options.onError(String(cannotStart && cannotStart.message || cannotStart))
|
|
@@ -1089,7 +1112,7 @@ return stopPromise
|
|
|
1089
1112
|
abort() {
|
|
1090
1113
|
stopped = true
|
|
1091
1114
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1092
|
-
try { recognition.abort() } catch (already) {
|
|
1115
|
+
try { recognition.abort() } catch (already) { }
|
|
1093
1116
|
},
|
|
1094
1117
|
}
|
|
1095
1118
|
}
|
|
@@ -1362,11 +1385,11 @@ modelMap,
|
|
|
1362
1385
|
function teardown(rec) {
|
|
1363
1386
|
if (!rec) return
|
|
1364
1387
|
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) {
|
|
1388
|
+
try { rec.stream.getTracks().forEach((t) => t.stop()) } catch (e) { }
|
|
1389
|
+
if (rec.srcNode) { try { rec.srcNode.disconnect() } catch (e) { } }
|
|
1390
|
+
if (rec.filterNode) { try { rec.filterNode.disconnect() } catch (e) { } }
|
|
1391
|
+
if (rec.analyser) { try { rec.analyser.disconnect() } catch (e) { } }
|
|
1392
|
+
if (rec.audioCtx) { try { rec.audioCtx.close() } catch (e) { } }
|
|
1370
1393
|
}
|
|
1371
1394
|
voice.teardownRec = teardown
|
|
1372
1395
|
function waitStop(recorder) {
|
|
@@ -1419,7 +1442,7 @@ filter.Q.value = 0.707
|
|
|
1419
1442
|
src.connect(filter)
|
|
1420
1443
|
lastNode = filter
|
|
1421
1444
|
rec.filterNode = filter
|
|
1422
|
-
} catch (e) {
|
|
1445
|
+
} catch (e) { }
|
|
1423
1446
|
rec.analyser = rec.audioCtx.createAnalyser()
|
|
1424
1447
|
rec.analyser.fftSize = 128
|
|
1425
1448
|
lastNode.connect(rec.analyser)
|
|
@@ -1528,7 +1551,7 @@ rec.streamMs = 0
|
|
|
1528
1551
|
if (!rec.closing && !rec.cancelled) {
|
|
1529
1552
|
try {
|
|
1530
1553
|
if (rec.recorder && rec.recorder.state === 'inactive') rec.recorder.start()
|
|
1531
|
-
} catch (e) {
|
|
1554
|
+
} catch (e) { }
|
|
1532
1555
|
}
|
|
1533
1556
|
rec.cutting = false
|
|
1534
1557
|
if (rec.cancelled || blob.size < 600) return // cancelled or too short — not speech
|
|
@@ -1552,7 +1575,8 @@ if (promptInfo && submitToStructuredPrompt(text, promptInfo)) {
|
|
|
1552
1575
|
return
|
|
1553
1576
|
}
|
|
1554
1577
|
}
|
|
1555
|
-
if (action === 'send' || action === 'clear' || action === 'newline' || action === 'undo_chunk') {
|
|
1578
|
+
if (action === 'send' || action === 'clear' || action === 'newline' || action === 'undo_chunk' || action === 'stop_generation' || action === 'switch_dictation' || action === 'switch_voice_note' || action === 'new_chat') {
|
|
1579
|
+
playAudioCue('success', { enabled: voice.settings?.audioFeedback !== false })
|
|
1556
1580
|
executeVoiceAction(action, text, target)
|
|
1557
1581
|
return
|
|
1558
1582
|
}
|
|
@@ -1669,6 +1693,7 @@ return
|
|
|
1669
1693
|
}
|
|
1670
1694
|
}
|
|
1671
1695
|
announceVoice('start')
|
|
1696
|
+
playAudioCue('start', { enabled: voice.settings?.audioFeedback !== false })
|
|
1672
1697
|
dictationQueue = Promise.resolve()
|
|
1673
1698
|
voice.set({ phase: 'recording', mode, error: '', levels: [], caption: '', interimTranscript: '' })
|
|
1674
1699
|
modeChain(mode).then((info) => {
|
|
@@ -1697,6 +1722,7 @@ voice.set({ phase: 'error', error: String(err && err.message ? err.message : err
|
|
|
1697
1722
|
function startDictation() { startRecording('dictation') }
|
|
1698
1723
|
function startMessage() { startRecording('message') }
|
|
1699
1724
|
function cancelCurrent() {
|
|
1725
|
+
playAudioCue('stop', { enabled: voice.settings?.audioFeedback !== false })
|
|
1700
1726
|
voice.activeOpId = (voice.activeOpId || 0) + 1
|
|
1701
1727
|
announceVoice('end')
|
|
1702
1728
|
focusComposer()
|
|
@@ -1715,10 +1741,11 @@ rec.closing = true
|
|
|
1715
1741
|
const stopped = waitStop(rec.recorder)
|
|
1716
1742
|
try {
|
|
1717
1743
|
if (rec.recorder && rec.recorder.state !== 'inactive') rec.recorder.stop()
|
|
1718
|
-
} catch (e) {
|
|
1744
|
+
} catch (e) { }
|
|
1719
1745
|
stopped.then(() => { teardown(rec); voice.rec = null; voice.set({ phase: 'idle', error: '' }) })
|
|
1720
1746
|
}
|
|
1721
1747
|
function stopCurrent() {
|
|
1748
|
+
playAudioCue('stop', { enabled: voice.settings?.audioFeedback !== false })
|
|
1722
1749
|
announceVoice('end')
|
|
1723
1750
|
focusComposer()
|
|
1724
1751
|
if (voice.browser) {
|
|
@@ -1761,7 +1788,7 @@ const mode = rec.mode
|
|
|
1761
1788
|
const stopped = waitStop(rec.recorder)
|
|
1762
1789
|
try {
|
|
1763
1790
|
if (rec.recorder && rec.recorder.state !== 'inactive') rec.recorder.stop()
|
|
1764
|
-
} catch (e) {
|
|
1791
|
+
} catch (e) { }
|
|
1765
1792
|
stopped.then(async () => {
|
|
1766
1793
|
if (voice.disposed || rec.cancelled || voice.activeOpId !== opId) {
|
|
1767
1794
|
teardown(rec)
|
|
@@ -1807,7 +1834,7 @@ voice.set({ phase: 'idle' })
|
|
|
1807
1834
|
return
|
|
1808
1835
|
}
|
|
1809
1836
|
}
|
|
1810
|
-
if (action === 'send' || action === 'clear' || action === 'newline' || action === 'undo_chunk') {
|
|
1837
|
+
if (action === 'send' || action === 'clear' || action === 'newline' || action === 'undo_chunk' || action === 'stop_generation' || action === 'switch_dictation' || action === 'switch_voice_note' || action === 'new_chat') {
|
|
1811
1838
|
executeVoiceAction(action, text, target)
|
|
1812
1839
|
return
|
|
1813
1840
|
}
|
|
@@ -1849,41 +1876,6 @@ await processTail()
|
|
|
1849
1876
|
}
|
|
1850
1877
|
})
|
|
1851
1878
|
}
|
|
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
1879
|
function submitPending() {
|
|
1888
1880
|
submitPendingPreview(voice)
|
|
1889
1881
|
}
|
|
@@ -1894,7 +1886,7 @@ function runSessionCommand(cmd) {
|
|
|
1894
1886
|
if (cmd === 'send') submitPending()
|
|
1895
1887
|
else if (cmd === 'cancel') cancelCurrent()
|
|
1896
1888
|
else if (cmd === 'stop') cancelCurrent()
|
|
1897
|
-
else if (cmd === 'continue') {
|
|
1889
|
+
else if (cmd === 'continue') { }
|
|
1898
1890
|
else if (cmd === 'undo_chunk') { executeVoiceAction('undo_chunk') }
|
|
1899
1891
|
}
|
|
1900
1892
|
function keepPending() {
|
|
@@ -1906,23 +1898,28 @@ voice.inputActions = props.inputActions
|
|
|
1906
1898
|
voice.input = props.input
|
|
1907
1899
|
if (v.phase !== 'idle' && v.phase !== 'error' && !hold.armed) return null
|
|
1908
1900
|
const err = v.phase === 'error'
|
|
1909
|
-
const hk = voice.hotkey ?
|
|
1901
|
+
const hk = voice.hotkey ? ' (' + voice.hotkey + ')' : ''
|
|
1910
1902
|
const curMode = voice.selectedDictationMode || (voice.settings && voice.settings.dictationMode) || 'clean'
|
|
1903
|
+
const showDictationMode = voice.settings ? voice.settings.showDictationModeButton !== false : true
|
|
1904
|
+
const showDictation = voice.settings ? voice.settings.showDictationButton !== false : true
|
|
1905
|
+
const showMessage = voice.settings ? voice.settings.showMessageButton !== false : true
|
|
1906
|
+
const hasLastNote = !!(voice.lastNote && voice.lastNote.url)
|
|
1907
|
+
if (!showDictationMode && !showDictation && !showMessage && !hasLastNote) return null
|
|
1911
1908
|
return h(React.Fragment, null,
|
|
1912
|
-
h('button', {
|
|
1909
|
+
showDictationMode ? h('button', {
|
|
1913
1910
|
type: 'button',
|
|
1914
1911
|
className: 'dvo-mode-pill-btn',
|
|
1915
1912
|
title: t('dictationModeTitle') + ': ' + getDictationModeLabel(curMode, t),
|
|
1916
1913
|
'aria-label': t('dictationModeTitle') + ': ' + getDictationModeLabel(curMode, t),
|
|
1917
1914
|
onClick: cycleDictationMode,
|
|
1918
|
-
}, getDictationModeLabel(curMode, t)),
|
|
1919
|
-
h('button', {
|
|
1915
|
+
}, getDictationModeLabel(curMode, t)) : null,
|
|
1916
|
+
showDictation ? h('button', {
|
|
1920
1917
|
type: 'button', className: 'dvo-btn', 'data-err': err ? '1' : '0',
|
|
1921
1918
|
title: err ? v.error : t('dictationBtn'),
|
|
1922
1919
|
'aria-label': err ? v.error : t('dictationBtn'),
|
|
1923
1920
|
onClick: startDictation,
|
|
1924
|
-
}, micIcon()),
|
|
1925
|
-
h('button', {
|
|
1921
|
+
}, micIcon()) : null,
|
|
1922
|
+
showMessage ? h('button', {
|
|
1926
1923
|
type: 'button', className: 'dvo-btn' + (hold.armed ? ' dvo-btn-active' : ''), 'data-err': err ? '1' : '0',
|
|
1927
1924
|
title: err ? v.error : (t('messageBtn') + hk),
|
|
1928
1925
|
'aria-label': err ? v.error : (t('messageBtn') + hk),
|
|
@@ -1934,8 +1931,8 @@ if (hold.armed && (!e.target || typeof e.target.hasPointerCapture !== 'function'
|
|
|
1934
1931
|
endHold(true)
|
|
1935
1932
|
}
|
|
1936
1933
|
},
|
|
1937
|
-
}, waveIcon()),
|
|
1938
|
-
|
|
1934
|
+
}, waveIcon()) : null,
|
|
1935
|
+
hasLastNote
|
|
1939
1936
|
? h('button', {
|
|
1940
1937
|
type: 'button', className: 'dvo-btn' + (voice.showPlayer ? ' dvo-btn-active' : ''),
|
|
1941
1938
|
title: t('listenBack'),
|
|
@@ -2018,7 +2015,12 @@ const HOLD_THRESHOLD_MS = 350
|
|
|
2018
2015
|
const hold = { active: false, mode: null, startedAt: 0, armed: false }
|
|
2019
2016
|
let activePointerCleanup = null
|
|
2020
2017
|
function beginHold(mode, pointerEvent) {
|
|
2021
|
-
if (hold.armed || (voice.phase !== 'idle' && voice.phase !== 'error'))
|
|
2018
|
+
if (hold.armed || (voice.phase !== 'idle' && voice.phase !== 'error')) {
|
|
2019
|
+
if (voice.phase === 'recording' || voice.phase === 'pending') {
|
|
2020
|
+
stopCurrent()
|
|
2021
|
+
}
|
|
2022
|
+
return
|
|
2023
|
+
}
|
|
2022
2024
|
hold.armed = true
|
|
2023
2025
|
hold.mode = mode
|
|
2024
2026
|
hold.startedAt = Date.now()
|
|
@@ -2051,20 +2053,24 @@ voice.notify()
|
|
|
2051
2053
|
function endHold(cancelled) {
|
|
2052
2054
|
if (activePointerCleanup) { try { activePointerCleanup() } catch (e) {} }
|
|
2053
2055
|
if (!hold.armed) return
|
|
2056
|
+
const wasHeld = hold.active
|
|
2054
2057
|
hold.armed = false
|
|
2055
2058
|
voice.holding = false
|
|
2056
2059
|
voice.notify()
|
|
2057
|
-
if (cancelled)
|
|
2058
|
-
|
|
2060
|
+
if (cancelled) {
|
|
2061
|
+
cancelCurrent()
|
|
2062
|
+
} else if (wasHeld) {
|
|
2063
|
+
stopCurrent()
|
|
2064
|
+
}
|
|
2059
2065
|
}
|
|
2060
2066
|
let activeHotkeyCleanup = null
|
|
2061
2067
|
function clearGlobalHotkey() {
|
|
2062
2068
|
if (typeof activeHotkeyCleanup === 'function') {
|
|
2063
|
-
try { activeHotkeyCleanup() } catch (_) {
|
|
2069
|
+
try { activeHotkeyCleanup() } catch (_) { }
|
|
2064
2070
|
activeHotkeyCleanup = null
|
|
2065
2071
|
}
|
|
2066
2072
|
if (typeof window !== 'undefined' && typeof window.__dsh_voice_hotkey_cleanup === 'function') {
|
|
2067
|
-
try { window.__dsh_voice_hotkey_cleanup() } catch (_) {
|
|
2073
|
+
try { window.__dsh_voice_hotkey_cleanup() } catch (_) { }
|
|
2068
2074
|
window.__dsh_voice_hotkey_cleanup = null
|
|
2069
2075
|
}
|
|
2070
2076
|
}
|
|
@@ -2352,6 +2358,47 @@ p.sessionMismatch
|
|
|
2352
2358
|
: null,
|
|
2353
2359
|
)
|
|
2354
2360
|
}
|
|
2361
|
+
function clearDraft(target) {
|
|
2362
|
+
const actions = (target || voice._activeTarget)?.actions || voice.inputActions
|
|
2363
|
+
if (typeof actions?.setDraft === 'function') actions.setDraft('')
|
|
2364
|
+
}
|
|
2365
|
+
function executeVoiceAction(action, rawText, target) {
|
|
2366
|
+
const activeTarget = target || voice._activeTarget
|
|
2367
|
+
const acts = (activeTarget && activeTarget.actions) || voice.inputActions
|
|
2368
|
+
if (action === 'send') {
|
|
2369
|
+
const text = rawText.replace(/(^|[\s,.!?])(отправь|пошли|send)([\s,.!?]|$)/gi, '').trim()
|
|
2370
|
+
if (text) appendDraft(text, activeTarget)
|
|
2371
|
+
if (typeof acts?.submit === 'function') acts.submit()
|
|
2372
|
+
voice.set({ phase: 'idle' })
|
|
2373
|
+
} else if (action === 'clear') {
|
|
2374
|
+
clearDraft(activeTarget)
|
|
2375
|
+
voice.set({ phase: 'idle' })
|
|
2376
|
+
} else if (action === 'stop_generation') {
|
|
2377
|
+
if (acts?.stop) acts.stop()
|
|
2378
|
+
else {
|
|
2379
|
+
const btn = typeof document !== 'undefined' && document.querySelector('[data-action="stop"], [aria-label*="Stop"], button.dsw-stop-btn, .chat-stop-btn')
|
|
2380
|
+
if (btn) btn.click()
|
|
2381
|
+
}
|
|
2382
|
+
voice.set({ phase: 'idle' })
|
|
2383
|
+
} else if (action === 'switch_dictation') {
|
|
2384
|
+
voice.activeMode = 'dictation'; voice.notify()
|
|
2385
|
+
} else if (action === 'switch_voice_note') {
|
|
2386
|
+
voice.activeMode = 'note'; voice.notify()
|
|
2387
|
+
} else if (action === 'new_chat') {
|
|
2388
|
+
const newBtn = typeof document !== 'undefined' && document.querySelector('[data-action="new-chat"], button.new-chat-btn, [aria-label*="New topic"], [aria-label*="Новый диалог"]')
|
|
2389
|
+
if (newBtn) newBtn.click()
|
|
2390
|
+
voice.set({ phase: 'idle' })
|
|
2391
|
+
} else if (action === 'newline') {
|
|
2392
|
+
const payload = rawText.replace(/(^|[\s,.!?])(с новой строки|новая строка|абзац|new line|paragraph)([\s,.!?]|$)/gi, '').trim()
|
|
2393
|
+
appendDraft(payload, activeTarget)
|
|
2394
|
+
voice.set({ phase: 'idle' })
|
|
2395
|
+
} else if (action === 'undo_chunk') {
|
|
2396
|
+
undoLastInsert().then((msg) => {
|
|
2397
|
+
voice.lastUndoNotice = msg; voice.notify()
|
|
2398
|
+
setTimeout(() => { if (voice.lastUndoNotice === msg) { voice.lastUndoNotice = ''; voice.notify() } }, 3500)
|
|
2399
|
+
})
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2355
2402
|
const DICTATION_MODES = ['clean', 'task', 'note', 'verbatim']
|
|
2356
2403
|
function getDictationModeLabel(m, t) {
|
|
2357
2404
|
const trans = t || moduleT
|
|
@@ -2381,7 +2428,7 @@ if (pick) {
|
|
|
2381
2428
|
_accentColorCache = { color: pick, expires: now + 1000 }
|
|
2382
2429
|
return pick
|
|
2383
2430
|
}
|
|
2384
|
-
} catch (noTheme) {
|
|
2431
|
+
} catch (noTheme) { }
|
|
2385
2432
|
return fallback || voice.waveColor || 'currentColor'
|
|
2386
2433
|
}
|
|
2387
2434
|
function softColor(fallback) {
|
|
@@ -2395,7 +2442,7 @@ if (pick) {
|
|
|
2395
2442
|
_softColorCache = { color: pick, expires: now + 1000 }
|
|
2396
2443
|
return pick
|
|
2397
2444
|
}
|
|
2398
|
-
} catch (noTheme) {
|
|
2445
|
+
} catch (noTheme) { }
|
|
2399
2446
|
return fallback || voice.waveColor || 'currentColor'
|
|
2400
2447
|
}
|
|
2401
2448
|
function drawLiquidWave(g, w, h, levels, color, time) {
|
|
@@ -2873,9 +2920,14 @@ techJargonCorrection: data && data.techJargonCorrection !== false,
|
|
|
2873
2920
|
jargonDictionary: Array.isArray(data && data.jargonDictionary) ? data.jargonDictionary : [],
|
|
2874
2921
|
liveInterimPreview: data && data.liveInterimPreview !== false,
|
|
2875
2922
|
structuredPromptVoice: data && data.structuredPromptVoice !== false,
|
|
2923
|
+
audioFeedback: data && data.audioFeedback !== false,
|
|
2924
|
+
showDictationModeButton: data ? data.showDictationModeButton !== false : true,
|
|
2925
|
+
showDictationButton: data ? data.showDictationButton !== false : true,
|
|
2926
|
+
showMessageButton: data ? data.showMessageButton !== false : true,
|
|
2876
2927
|
})
|
|
2928
|
+
voice.notify()
|
|
2877
2929
|
})
|
|
2878
|
-
.catch(() => {
|
|
2930
|
+
.catch(() => { })
|
|
2879
2931
|
}
|
|
2880
2932
|
reload()
|
|
2881
2933
|
window.addEventListener('dsh-voice:settings-saved', reload)
|
|
@@ -3753,8 +3805,8 @@ const toggleTestMic = async () => {
|
|
|
3753
3805
|
if (testingMic) {
|
|
3754
3806
|
if (testRef.current) {
|
|
3755
3807
|
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) {
|
|
3808
|
+
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) { }
|
|
3809
|
+
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) { } }
|
|
3758
3810
|
testRef.current = null
|
|
3759
3811
|
}
|
|
3760
3812
|
setTestingMic(false)
|
|
@@ -3779,7 +3831,7 @@ filter.frequency.value = 80
|
|
|
3779
3831
|
filter.Q.value = 0.707
|
|
3780
3832
|
src.connect(filter)
|
|
3781
3833
|
lastNode = filter
|
|
3782
|
-
} catch (e) {
|
|
3834
|
+
} catch (e) { }
|
|
3783
3835
|
const analyser = audioCtx.createAnalyser()
|
|
3784
3836
|
analyser.fftSize = 128
|
|
3785
3837
|
lastNode.connect(analyser)
|
|
@@ -3804,8 +3856,8 @@ React.useEffect(() => {
|
|
|
3804
3856
|
return () => {
|
|
3805
3857
|
if (testRef.current) {
|
|
3806
3858
|
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) {
|
|
3859
|
+
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) { }
|
|
3860
|
+
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) { } }
|
|
3809
3861
|
testRef.current = null
|
|
3810
3862
|
}
|
|
3811
3863
|
}
|
|
@@ -4219,13 +4271,13 @@ ctx.configForms.describe().load()
|
|
|
4219
4271
|
} else if (ctx.settingsScope && typeof ctx.settingsScope.describe === 'function') {
|
|
4220
4272
|
ctx.settingsScope.describe().load()
|
|
4221
4273
|
}
|
|
4222
|
-
} catch (e) {
|
|
4274
|
+
} catch (e) { }
|
|
4223
4275
|
}, 1000)
|
|
4224
4276
|
return () => clearInterval(timer)
|
|
4225
4277
|
}, [ready])
|
|
4226
4278
|
const deepClone = (obj) => {
|
|
4227
4279
|
if (typeof structuredClone === 'function') {
|
|
4228
|
-
try { return structuredClone(obj) } catch (e) {
|
|
4280
|
+
try { return structuredClone(obj) } catch (e) { }
|
|
4229
4281
|
}
|
|
4230
4282
|
try { return JSON.parse(JSON.stringify(obj)) } catch (e) { return Object.assign({}, obj) }
|
|
4231
4283
|
}
|
|
@@ -4289,7 +4341,11 @@ autoSendVisualRing: val.autoSendVisualRing !== false,
|
|
|
4289
4341
|
voiceActions: val.voiceActions !== false,
|
|
4290
4342
|
techJargonCorrection: val.techJargonCorrection !== false,
|
|
4291
4343
|
liveInterimPreview: val.liveInterimPreview !== false,
|
|
4344
|
+
audioFeedback: val.audioFeedback !== false,
|
|
4292
4345
|
structuredPromptVoice: val.structuredPromptVoice !== false,
|
|
4346
|
+
showDictationModeButton: val.showDictationModeButton !== false,
|
|
4347
|
+
showDictationButton: val.showDictationButton !== false,
|
|
4348
|
+
showMessageButton: val.showMessageButton !== false,
|
|
4293
4349
|
dictationMode: val.dictationMode || 'clean',
|
|
4294
4350
|
dictationPrompts: val.dictationPrompts || {},
|
|
4295
4351
|
voiceMacros: Array.isArray(val.voiceMacros) ? val.voiceMacros : [],
|
|
@@ -4366,7 +4422,6 @@ for (const k of Object.keys(draft)) {
|
|
|
4366
4422
|
try {
|
|
4367
4423
|
await scope.set(k, draft[k])
|
|
4368
4424
|
} catch (e) {
|
|
4369
|
-
/* best effort on loopback */
|
|
4370
4425
|
}
|
|
4371
4426
|
}
|
|
4372
4427
|
}
|
|
@@ -4402,13 +4457,26 @@ autoSendVisualRing: d.autoSendVisualRing !== false,
|
|
|
4402
4457
|
voiceActions: d.voiceActions !== false,
|
|
4403
4458
|
techJargonCorrection: d.techJargonCorrection !== false,
|
|
4404
4459
|
liveInterimPreview: d.liveInterimPreview !== false,
|
|
4460
|
+
audioFeedback: d.audioFeedback !== false,
|
|
4405
4461
|
structuredPromptVoice: d.structuredPromptVoice !== false,
|
|
4462
|
+
showDictationModeButton: d.showDictationModeButton !== false,
|
|
4463
|
+
showDictationButton: d.showDictationButton !== false,
|
|
4464
|
+
showMessageButton: d.showMessageButton !== false,
|
|
4406
4465
|
})
|
|
4407
|
-
try { window.dispatchEvent(new CustomEvent('dsh-voice:settings-saved')) } catch (noEvents) {
|
|
4408
|
-
setSaved(true); setJargonInput(null)
|
|
4466
|
+
try { window.dispatchEvent(new CustomEvent('dsh-voice:settings-saved')) } catch (noEvents) { }
|
|
4467
|
+
voice.notify(); setSaved(true); setJargonInput(null)
|
|
4409
4468
|
setTimeout(() => setSaved(false), 2000)
|
|
4410
4469
|
fetchStatus()
|
|
4411
4470
|
}
|
|
4471
|
+
const checkItem = (k, label, defVal = true) => h('label', { className: 'cb-check-label' },
|
|
4472
|
+
h('input', {
|
|
4473
|
+
type: 'checkbox',
|
|
4474
|
+
checked: defVal ? (draft ? draft[k] !== false : true) : !!(draft && draft[k]),
|
|
4475
|
+
disabled: !writable,
|
|
4476
|
+
onChange: (e) => setTop(k, e.target.checked),
|
|
4477
|
+
}),
|
|
4478
|
+
label,
|
|
4479
|
+
)
|
|
4412
4480
|
const modeVal = (mode, key, fallback) => {
|
|
4413
4481
|
const m = draft && draft[mode]
|
|
4414
4482
|
return m && m[key] !== undefined ? m[key] : fallback
|
|
@@ -4585,24 +4653,8 @@ h('span', null, '🎙️ ' + t('turnTakingTitle')),
|
|
|
4585
4653
|
),
|
|
4586
4654
|
h('div', { className: 'cb-section-desc' }, t('turnTakingDesc')),
|
|
4587
4655
|
h('div', { className: 'cb-grid-2' },
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
type: 'checkbox',
|
|
4591
|
-
checked: draft ? draft.gatedTurnTaking !== false : true,
|
|
4592
|
-
disabled: !writable,
|
|
4593
|
-
onChange: (e) => setTop('gatedTurnTaking', e.target.checked),
|
|
4594
|
-
}),
|
|
4595
|
-
t('gatedTurnTaking'),
|
|
4596
|
-
),
|
|
4597
|
-
h('label', { className: 'cb-check-label' },
|
|
4598
|
-
h('input', {
|
|
4599
|
-
type: 'checkbox',
|
|
4600
|
-
checked: !!(draft && draft.bargeIn),
|
|
4601
|
-
disabled: !writable,
|
|
4602
|
-
onChange: (e) => setTop('bargeIn', e.target.checked),
|
|
4603
|
-
}),
|
|
4604
|
-
t('bargeInDesc'),
|
|
4605
|
-
),
|
|
4656
|
+
checkItem('gatedTurnTaking', t('gatedTurnTaking')),
|
|
4657
|
+
checkItem('bargeIn', t('bargeInDesc'), false),
|
|
4606
4658
|
),
|
|
4607
4659
|
),
|
|
4608
4660
|
h('div', { className: 'cb-section-card' },
|
|
@@ -4610,42 +4662,14 @@ h('div', { className: 'cb-section-title' },
|
|
|
4610
4662
|
h('span', null, '✨ ' + t('smartActionsTitle')),
|
|
4611
4663
|
),
|
|
4612
4664
|
h('div', { className: 'cb-grid-2' },
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
t('
|
|
4621
|
-
),
|
|
4622
|
-
h('label', { className: 'cb-check-label' },
|
|
4623
|
-
h('input', {
|
|
4624
|
-
type: 'checkbox',
|
|
4625
|
-
checked: draft ? draft.autoSendVisualRing !== false : true,
|
|
4626
|
-
disabled: !writable,
|
|
4627
|
-
onChange: (e) => setTop('autoSendVisualRing', e.target.checked),
|
|
4628
|
-
}),
|
|
4629
|
-
t('autoSendVisualRing'),
|
|
4630
|
-
),
|
|
4631
|
-
h('label', { className: 'cb-check-label' },
|
|
4632
|
-
h('input', {
|
|
4633
|
-
type: 'checkbox',
|
|
4634
|
-
checked: draft ? draft.voiceActions !== false : true,
|
|
4635
|
-
disabled: !writable,
|
|
4636
|
-
onChange: (e) => setTop('voiceActions', e.target.checked),
|
|
4637
|
-
}),
|
|
4638
|
-
t('voiceActionsLabel'),
|
|
4639
|
-
),
|
|
4640
|
-
h('label', { className: 'cb-check-label' },
|
|
4641
|
-
h('input', {
|
|
4642
|
-
type: 'checkbox',
|
|
4643
|
-
checked: draft ? draft.structuredPromptVoice !== false : true,
|
|
4644
|
-
disabled: !writable,
|
|
4645
|
-
onChange: (e) => setTop('structuredPromptVoice', e.target.checked),
|
|
4646
|
-
}),
|
|
4647
|
-
t('structuredPromptVoice'),
|
|
4648
|
-
),
|
|
4665
|
+
checkItem('liveInterimPreview', t('liveInterimPreview')),
|
|
4666
|
+
checkItem('autoSendVisualRing', t('autoSendVisualRing')),
|
|
4667
|
+
checkItem('voiceActions', t('voiceActionsLabel')),
|
|
4668
|
+
checkItem('structuredPromptVoice', t('structuredPromptVoice')),
|
|
4669
|
+
checkItem('audioFeedback', t('audioFeedback')),
|
|
4670
|
+
checkItem('showDictationModeButton', t('showDictationModeBtn')),
|
|
4671
|
+
checkItem('showDictationButton', t('showDictationBtn')),
|
|
4672
|
+
checkItem('showMessageButton', t('showMessageBtn')),
|
|
4649
4673
|
),
|
|
4650
4674
|
),
|
|
4651
4675
|
h(DictationModesSection, {
|
package/lib/host-routes.js
CHANGED
|
@@ -96,7 +96,11 @@ export function registerHostRoutes(ctx, deps) {
|
|
|
96
96
|
techJargonCorrection: cfg.techJargonCorrection !== false,
|
|
97
97
|
jargonDictionary: Array.isArray(cfg.jargonDictionary) ? cfg.jargonDictionary : [],
|
|
98
98
|
liveInterimPreview: cfg.liveInterimPreview !== false,
|
|
99
|
+
audioFeedback: cfg.audioFeedback !== false,
|
|
99
100
|
structuredPromptVoice: cfg.structuredPromptVoice !== false,
|
|
101
|
+
showDictationModeButton: cfg.showDictationModeButton !== false,
|
|
102
|
+
showDictationButton: cfg.showDictationButton !== false,
|
|
103
|
+
showMessageButton: cfg.showMessageButton !== false,
|
|
100
104
|
dictationMode: cfg.dictationMode || 'clean',
|
|
101
105
|
dictationPrompts: cfg.dictationPrompts || {},
|
|
102
106
|
voiceMacros: Array.isArray(cfg.voiceMacros) ? cfg.voiceMacros : [],
|
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,8 +168,16 @@ 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.'),
|
|
175
|
+
showDictationModeButton: z.boolean().default(true)
|
|
176
|
+
.description('Show dictation processing mode cycle button in composer.'),
|
|
177
|
+
showDictationButton: z.boolean().default(true)
|
|
178
|
+
.description('Show voice typing (microphone) button in composer.'),
|
|
179
|
+
showMessageButton: z.boolean().default(true)
|
|
180
|
+
.description('Show voice message button in composer.'),
|
|
173
181
|
dictationMode: z.union(['verbatim', 'clean', 'task', 'note', 'bug']).default('clean')
|
|
174
182
|
.description('Dictation post-processing mode: "verbatim", "clean", "task", or "note".'),
|
|
175
183
|
dictationPrompts: z.object({
|
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.54",
|
|
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",
|