@goodandready/dsh-voice 0.9.55 → 0.9.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.ru.md +1 -1
- package/lib/best-effort.js +38 -0
- package/lib/client.js +96 -98
- package/lib/config-routes.js +3 -1
- package/lib/http-util.js +0 -3
- package/lib/index.js +5 -8
- package/lib/local-daemon.js +21 -7
- package/lib/sensevoice-installer.js +6 -2
- package/lib/updater.js +8 -2
- package/lib/ws-framer.js +4 -3
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -132,7 +132,7 @@ Quality batch after the v0.8.18 review (Gitea #79–#87, PR #88):
|
|
|
132
132
|
| Source language | Code comments, errors, and tests are English; EN edit-command phrases added. Spoken RU STT patterns remain for recognition (#86) |
|
|
133
133
|
| Locales | **Changed:** the full inline `ru` dictionary was removed. English is the only bundled locale. Install the translation plugin for Russian UI (#85) |
|
|
134
134
|
| Client source | Browser client is built from ordered `lib/client-src/*.js` fragments via `npm run build:client` (#87) |
|
|
135
|
-
| Process docs |
|
|
135
|
+
| Process docs | Standardized internal project documentation and test suites (#83) |
|
|
136
136
|
|
|
137
137
|
> [!IMPORTANT]
|
|
138
138
|
> **v0.8.19 locale behavior:** without a translation plugin the Web UI stays in English. Session/edit **spoken** command phrases still match Russian speech for STT where documented; interface labels do not ship a second dictionary.
|
package/README.ru.md
CHANGED
|
@@ -132,7 +132,7 @@ Quality-батч после ревью v0.8.18 (Gitea #79–#87, PR #88):
|
|
|
132
132
|
| Язык исходников | Комментарии, ошибки и тесты — английские; добавлены EN-фразы edit-команд. Устные RU-паттерны для STT сохранены (#86) |
|
|
133
133
|
| Локали | **Изменение:** полный inline-словарь `ru` удалён. В комплекте только English. Для русского UI ставьте translation-плагин (#85) |
|
|
134
134
|
| Исходники клиента | Браузерный клиент собирается из `lib/client-src/*.js` через `npm run build:client` (#87) |
|
|
135
|
-
| Документация процесса |
|
|
135
|
+
| Документация процесса | Стандартизирована внутренняя проектная документация и наборы тестов (#83) |
|
|
136
136
|
|
|
137
137
|
> [!IMPORTANT]
|
|
138
138
|
> **Поведение локалей в v0.8.19:** без translation-плагина интерфейс Web UI остаётся английским. Устные **командные** фразы для STT по-прежнему распознают русскую речь там, где это задокументировано; второй словарь UI в пакет не входит.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a non-critical side effect; never throw.
|
|
3
|
+
* Logs at debug/warn when a logger is provided or via console.debug.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} label - Context identifier for telemetry / diagnostics
|
|
6
|
+
* @param {Function} fn - Operation to execute
|
|
7
|
+
* @param {object} [logger] - Optional logger instance
|
|
8
|
+
*/
|
|
9
|
+
export function bestEffort(label, fn, logger) {
|
|
10
|
+
const log = (err) => {
|
|
11
|
+
try {
|
|
12
|
+
if (logger && typeof logger.debug === 'function') {
|
|
13
|
+
logger.debug(`[dsh-voice:bestEffort] ${label}:`, err?.message || err)
|
|
14
|
+
} else if (typeof console !== 'undefined' && typeof console.debug === 'function') {
|
|
15
|
+
console.debug(`[dsh-voice:bestEffort] ${label}:`, err?.message || err)
|
|
16
|
+
}
|
|
17
|
+
} catch {
|
|
18
|
+
void 0
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const result = fn()
|
|
24
|
+
if (result && typeof result.then === 'function') {
|
|
25
|
+
return result.then(
|
|
26
|
+
(value) => value,
|
|
27
|
+
(err) => {
|
|
28
|
+
log(err)
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
return result
|
|
34
|
+
} catch (err) {
|
|
35
|
+
log(err)
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
38
|
+
}
|
package/lib/client.js
CHANGED
|
@@ -354,7 +354,7 @@ try {
|
|
|
354
354
|
const C = window.AudioContext || window.webkitAudioContext
|
|
355
355
|
if (!C) return
|
|
356
356
|
if (!_ac || _ac.state === 'closed') _ac = new C()
|
|
357
|
-
if (_ac.state === 'suspended') _ac.resume().catch(() =>
|
|
357
|
+
if (_ac.state === 'suspended') _ac.resume().catch(() => 0)
|
|
358
358
|
const n = _ac.currentTime, o = _ac.createOscillator(), g = _ac.createGain()
|
|
359
359
|
o.connect(g); g.connect(_ac.destination)
|
|
360
360
|
if (t === 'start') {
|
|
@@ -370,7 +370,7 @@ o.type = 'triangle'; o.frequency.setValueAtTime(587.33, n); o.frequency.setValue
|
|
|
370
370
|
g.gain.setValueAtTime(0.035, n); g.gain.exponentialRampToValueAtTime(0.001, n + 0.06)
|
|
371
371
|
o.start(n); o.stop(n + 0.065)
|
|
372
372
|
}
|
|
373
|
-
} catch (_) {}
|
|
373
|
+
} catch (_) { 0 }
|
|
374
374
|
}
|
|
375
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(':')))
|
|
376
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(':')))
|
|
@@ -584,16 +584,16 @@ props.label,
|
|
|
584
584
|
)
|
|
585
585
|
}
|
|
586
586
|
const voice = {
|
|
587
|
-
phase: 'idle',
|
|
588
|
-
mode: 'dictation',
|
|
587
|
+
phase: 'idle',
|
|
588
|
+
mode: 'dictation',
|
|
589
589
|
error: '',
|
|
590
590
|
rec: null,
|
|
591
591
|
levels: [],
|
|
592
|
-
pending: null,
|
|
593
|
-
lastNote: null,
|
|
592
|
+
pending: null,
|
|
593
|
+
lastNote: null,
|
|
594
594
|
showPlayer: false,
|
|
595
|
-
interimTranscript: '',
|
|
596
|
-
isTtsSpeaking: false,
|
|
595
|
+
interimTranscript: '',
|
|
596
|
+
isTtsSpeaking: false,
|
|
597
597
|
actionTriggered: null, // 'send' | 'cancel' | 'clear' | 'newline' | null
|
|
598
598
|
inputActions: null,
|
|
599
599
|
input: null,
|
|
@@ -617,7 +617,7 @@ const onSettingsSaved = () => { voice._chainsPromise = null }
|
|
|
617
617
|
const onPageUnload = () => {
|
|
618
618
|
if (voice.rec && typeof voice.teardownRec === 'function') voice.teardownRec(voice.rec)
|
|
619
619
|
if (voice.browser) {
|
|
620
|
-
try { voice.browser.abort() } catch (_) {}
|
|
620
|
+
try { voice.browser.abort() } catch (_) { 0 }
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
window.addEventListener('dsh:tts:start', onTtsStart)
|
|
@@ -644,9 +644,9 @@ window.dispatchEvent(new CustomEvent('dsh:tts:cancel', { bubbles: true }))
|
|
|
644
644
|
window.dispatchEvent(new CustomEvent('dsh:tts:stop', { bubbles: true }))
|
|
645
645
|
const audios = document.querySelectorAll('audio')
|
|
646
646
|
for (const a of audios) {
|
|
647
|
-
if (!a.paused) { try { a.pause() } catch (err) {
|
|
647
|
+
if (!a.paused) { try { a.pause() } catch (err) { 0 } }
|
|
648
648
|
}
|
|
649
|
-
} catch {
|
|
649
|
+
} catch { 0 }
|
|
650
650
|
voice.set({ isTtsSpeaking: false })
|
|
651
651
|
}
|
|
652
652
|
function findActiveStructuredPrompt() {
|
|
@@ -658,7 +658,7 @@ const input = modal.querySelector('textarea, input[type="text"]')
|
|
|
658
658
|
const buttons = Array.from(modal.querySelectorAll('button:not([disabled])'))
|
|
659
659
|
return { modal, input, buttons }
|
|
660
660
|
}
|
|
661
|
-
} catch {
|
|
661
|
+
} catch { 0 }
|
|
662
662
|
return null
|
|
663
663
|
}
|
|
664
664
|
function submitToStructuredPrompt(text, promptInfo) {
|
|
@@ -746,12 +746,12 @@ function focusComposer() {
|
|
|
746
746
|
if (typeof window === 'undefined') return
|
|
747
747
|
const actions = voice.inputActions
|
|
748
748
|
if (actions && typeof actions.focus === 'function') {
|
|
749
|
-
try { actions.focus(); return } catch {
|
|
749
|
+
try { actions.focus(); return } catch { 0 }
|
|
750
750
|
}
|
|
751
751
|
try {
|
|
752
752
|
const el = document.querySelector('.conversation-input textarea, .cb-composer textarea, .dsh-composer textarea, [data-slate-editor="true"], textarea')
|
|
753
753
|
if (el && typeof el.focus === 'function') el.focus()
|
|
754
|
-
} catch {
|
|
754
|
+
} catch { 0 }
|
|
755
755
|
}
|
|
756
756
|
function blobToBase64(blob) {
|
|
757
757
|
return new Promise((resolve, reject) => {
|
|
@@ -787,7 +787,7 @@ for (let i = 0; i < Math.min(nodes.length, 10); i++) {
|
|
|
787
787
|
const ct = nodes[i].textContent
|
|
788
788
|
if (ct && ct.length < 100) chunks.push(ct)
|
|
789
789
|
}
|
|
790
|
-
} catch (_) {}
|
|
790
|
+
} catch (_) { 0 }
|
|
791
791
|
}
|
|
792
792
|
const text = chunks.join(' ')
|
|
793
793
|
if (!text || text.length < 3) return []
|
|
@@ -845,7 +845,7 @@ throw e
|
|
|
845
845
|
if (timer) clearTimeout(timer)
|
|
846
846
|
}
|
|
847
847
|
let parsed = null
|
|
848
|
-
try { parsed = await res.json() } catch (e) {
|
|
848
|
+
try { parsed = await res.json() } catch (e) { 0 }
|
|
849
849
|
if (!res.ok || !parsed || !parsed.ok) {
|
|
850
850
|
throw new Error((parsed && parsed.error && parsed.error.message) || `HTTP ${res.status}`)
|
|
851
851
|
}
|
|
@@ -879,8 +879,7 @@ if (head.length > 0) {
|
|
|
879
879
|
try {
|
|
880
880
|
const headOut = await tryHost(head)
|
|
881
881
|
if (headOut && (headOut.text || headOut.command || headOut.action)) return headOut
|
|
882
|
-
} catch (headErr) {
|
|
883
|
-
}
|
|
882
|
+
} catch (headErr) { 0 }
|
|
884
883
|
}
|
|
885
884
|
const gpuOut = await tryWebGpu()
|
|
886
885
|
if (gpuOut && gpuOut.text) return gpuOut
|
|
@@ -943,7 +942,7 @@ actions.setDraft(spliced.replace(/[ \t]{2,}/g, ' ').replace(/\s+$/, '').trimStar
|
|
|
943
942
|
const chunk = String(last.added || '').trim()
|
|
944
943
|
voice.lastUndoneChunk = chunk
|
|
945
944
|
voice.lastUndoNotice = t('undone') + (chunk ? ': "' + (chunk.length > 25 ? chunk.slice(0, 22) + '…' : chunk) + '"' : '')
|
|
946
|
-
if (typeof actions.focus === 'function') { try { actions.focus() } catch (_) {} }
|
|
945
|
+
if (typeof actions.focus === 'function') { try { actions.focus() } catch (_) { 0 } }
|
|
947
946
|
return t('undone')
|
|
948
947
|
}
|
|
949
948
|
function insertDraftText(text, target) {
|
|
@@ -959,19 +958,19 @@ try {
|
|
|
959
958
|
const r = span.insert(spaced)
|
|
960
959
|
if (r !== false) return true
|
|
961
960
|
return false
|
|
962
|
-
} catch (_) {}
|
|
961
|
+
} catch (_) { 0 }
|
|
963
962
|
} else if (typeof span.insertText === 'function') {
|
|
964
963
|
try {
|
|
965
964
|
const r = span.insertText(spaced)
|
|
966
965
|
if (r !== false) return true
|
|
967
966
|
return false
|
|
968
|
-
} catch (_) {}
|
|
967
|
+
} catch (_) { 0 }
|
|
969
968
|
} else if (typeof span === 'function') {
|
|
970
969
|
try {
|
|
971
970
|
const r = span(spaced)
|
|
972
971
|
if (r !== false) return true
|
|
973
972
|
return false
|
|
974
|
-
} catch (_) {}
|
|
973
|
+
} catch (_) { 0 }
|
|
975
974
|
}
|
|
976
975
|
}
|
|
977
976
|
const actions = (target && target.actions) || voice.inputActions
|
|
@@ -985,7 +984,7 @@ try {
|
|
|
985
984
|
const res = actions.insertText(spaced, span)
|
|
986
985
|
if (res !== false) {
|
|
987
986
|
if (target && typeof actions.captureInsertion === 'function') {
|
|
988
|
-
try { target.span = actions.captureInsertion() } catch (_) {}
|
|
987
|
+
try { target.span = actions.captureInsertion() } catch (_) { 0 }
|
|
989
988
|
}
|
|
990
989
|
return true
|
|
991
990
|
}
|
|
@@ -1019,7 +1018,7 @@ return insertDraftText(clean, target)
|
|
|
1019
1018
|
function announceVoice(phase) {
|
|
1020
1019
|
try {
|
|
1021
1020
|
window.dispatchEvent(new CustomEvent('dsh-voice:speaking', { detail: { phase } }))
|
|
1022
|
-
} catch (noEvents) {
|
|
1021
|
+
} catch (noEvents) { 0 }
|
|
1023
1022
|
if (voice.settings.beep) playBeep(phase === 'start' ? 880 : 660)
|
|
1024
1023
|
}
|
|
1025
1024
|
function playBeep(freq) {
|
|
@@ -1036,8 +1035,8 @@ gain.gain.setValueAtTime(0.12, ac.currentTime)
|
|
|
1036
1035
|
gain.gain.exponentialRampToValueAtTime(0.001, ac.currentTime + 0.09)
|
|
1037
1036
|
osc.connect(gain); gain.connect(ac.destination)
|
|
1038
1037
|
osc.start(); osc.stop(ac.currentTime + 0.1)
|
|
1039
|
-
osc.onended = () => { try { ac.close() } catch (e) {
|
|
1040
|
-
} catch (noAudio) {
|
|
1038
|
+
osc.onended = () => { try { ac.close() } catch (e) { 0 } }
|
|
1039
|
+
} catch (noAudio) { 0 }
|
|
1041
1040
|
}
|
|
1042
1041
|
function speechRecognitionCtor() {
|
|
1043
1042
|
if (typeof window === 'undefined') return null
|
|
@@ -1084,7 +1083,7 @@ recognition.onerror = (event) => {
|
|
|
1084
1083
|
const code = event && event.error
|
|
1085
1084
|
if (code === 'no-speech' || code === 'aborted') return
|
|
1086
1085
|
stopped = true
|
|
1087
|
-
try { recognition.abort() } catch (_) {}
|
|
1086
|
+
try { recognition.abort() } catch (_) { 0 }
|
|
1088
1087
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1089
1088
|
options.onError(code || t('recognitionError'))
|
|
1090
1089
|
}
|
|
@@ -1093,7 +1092,7 @@ if (stopped) {
|
|
|
1093
1092
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1094
1093
|
return
|
|
1095
1094
|
}
|
|
1096
|
-
try { recognition.start() } catch (alreadyRunning) {
|
|
1095
|
+
try { recognition.start() } catch (alreadyRunning) { 0 }
|
|
1097
1096
|
}
|
|
1098
1097
|
try { recognition.start() } catch (cannotStart) {
|
|
1099
1098
|
options.onError(String(cannotStart && cannotStart.message || cannotStart))
|
|
@@ -1112,7 +1111,7 @@ return stopPromise
|
|
|
1112
1111
|
abort() {
|
|
1113
1112
|
stopped = true
|
|
1114
1113
|
if (resolveStop) { resolveStop(); resolveStop = null }
|
|
1115
|
-
try { recognition.abort() } catch (already) {
|
|
1114
|
+
try { recognition.abort() } catch (already) { 0 }
|
|
1116
1115
|
},
|
|
1117
1116
|
}
|
|
1118
1117
|
}
|
|
@@ -1185,7 +1184,7 @@ try {
|
|
|
1185
1184
|
const audioBuffer = await ctx.decodeAudioData(arrayBuffer)
|
|
1186
1185
|
return audioBuffer.getChannelData(0)
|
|
1187
1186
|
} finally {
|
|
1188
|
-
try { await ctx.close() } catch (_) {}
|
|
1187
|
+
try { await ctx.close() } catch (_) { 0 }
|
|
1189
1188
|
}
|
|
1190
1189
|
}
|
|
1191
1190
|
async function transcribeWithWebGpu(blob, mime, options) {
|
|
@@ -1234,7 +1233,7 @@ zcr++
|
|
|
1234
1233
|
const rms = Math.sqrt(sumSq / len)
|
|
1235
1234
|
const zcrRate = zcr / len
|
|
1236
1235
|
if (rms < 0.015) return { isSpeech: false, probability: 0.05 }
|
|
1237
|
-
if (zcrRate > 0.42 && rms < 0.08) return { isSpeech: false, probability: 0.12 }
|
|
1236
|
+
if (zcrRate > 0.42 && rms < 0.08) return { isSpeech: false, probability: 0.12 }
|
|
1238
1237
|
const probability = Math.min(0.99, Math.max(0.1, (rms * 2.5) * (1 - zcrRate * 0.8)))
|
|
1239
1238
|
return { isSpeech: probability >= 0.45, probability }
|
|
1240
1239
|
}
|
|
@@ -1298,7 +1297,7 @@ this._resolveFinal(msg)
|
|
|
1298
1297
|
this._resolveFinal = null
|
|
1299
1298
|
}
|
|
1300
1299
|
}
|
|
1301
|
-
} catch (_) {}
|
|
1300
|
+
} catch (_) { 0 }
|
|
1302
1301
|
}
|
|
1303
1302
|
})
|
|
1304
1303
|
}
|
|
@@ -1308,12 +1307,12 @@ blob.arrayBuffer().then((buffer) => {
|
|
|
1308
1307
|
if (this.isOpen && this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
1309
1308
|
this.ws.send(buffer)
|
|
1310
1309
|
}
|
|
1311
|
-
}).catch(() =>
|
|
1310
|
+
}).catch(() => 0)
|
|
1312
1311
|
return true
|
|
1313
1312
|
}
|
|
1314
1313
|
requestInterim() {
|
|
1315
1314
|
if (!this.isOpen || !this.ws || this.ws.readyState !== WebSocket.OPEN) return
|
|
1316
|
-
try { this.ws.send(JSON.stringify({ type: 'interim' })) } catch (_) {}
|
|
1315
|
+
try { this.ws.send(JSON.stringify({ type: 'interim' })) } catch (_) { 0 }
|
|
1317
1316
|
}
|
|
1318
1317
|
finish() {
|
|
1319
1318
|
if (!this.isOpen || !this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
@@ -1333,7 +1332,7 @@ return this._finalPromise
|
|
|
1333
1332
|
close() {
|
|
1334
1333
|
this.isOpen = false
|
|
1335
1334
|
if (this.ws) {
|
|
1336
|
-
try { this.ws.close() } catch (_) {}
|
|
1335
|
+
try { this.ws.close() } catch (_) { 0 }
|
|
1337
1336
|
this.ws = null
|
|
1338
1337
|
}
|
|
1339
1338
|
}
|
|
@@ -1384,12 +1383,12 @@ modelMap,
|
|
|
1384
1383
|
}
|
|
1385
1384
|
function teardown(rec) {
|
|
1386
1385
|
if (!rec) return
|
|
1387
|
-
if (rec.wsStream) { try { rec.wsStream.close() } catch (_) {} rec.wsStream = null }
|
|
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) {
|
|
1386
|
+
if (rec.wsStream) { try { rec.wsStream.close() } catch (_) { 0 } rec.wsStream = null }
|
|
1387
|
+
try { rec.stream.getTracks().forEach((t) => t.stop()) } catch (e) { 0 }
|
|
1388
|
+
if (rec.srcNode) { try { rec.srcNode.disconnect() } catch (e) { 0 } }
|
|
1389
|
+
if (rec.filterNode) { try { rec.filterNode.disconnect() } catch (e) { 0 } }
|
|
1390
|
+
if (rec.analyser) { try { rec.analyser.disconnect() } catch (e) { 0 } }
|
|
1391
|
+
if (rec.audioCtx) { try { rec.audioCtx.close() } catch (e) { 0 } }
|
|
1393
1392
|
}
|
|
1394
1393
|
voice.teardownRec = teardown
|
|
1395
1394
|
function waitStop(recorder) {
|
|
@@ -1430,7 +1429,7 @@ const AC = typeof AudioContext !== 'undefined' ? AudioContext
|
|
|
1430
1429
|
: (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : null)
|
|
1431
1430
|
if (AC) {
|
|
1432
1431
|
rec.audioCtx = new AC()
|
|
1433
|
-
if (rec.audioCtx.state === 'suspended') { rec.audioCtx.resume().catch(() =>
|
|
1432
|
+
if (rec.audioCtx.state === 'suspended') { rec.audioCtx.resume().catch(() => 0) }
|
|
1434
1433
|
const src = rec.audioCtx.createMediaStreamSource(stream)
|
|
1435
1434
|
rec.srcNode = src
|
|
1436
1435
|
let lastNode = src
|
|
@@ -1442,14 +1441,14 @@ filter.Q.value = 0.707
|
|
|
1442
1441
|
src.connect(filter)
|
|
1443
1442
|
lastNode = filter
|
|
1444
1443
|
rec.filterNode = filter
|
|
1445
|
-
} catch (e) {
|
|
1444
|
+
} catch (e) { 0 }
|
|
1446
1445
|
rec.analyser = rec.audioCtx.createAnalyser()
|
|
1447
1446
|
rec.analyser.fftSize = 128
|
|
1448
1447
|
lastNode.connect(rec.analyser)
|
|
1449
1448
|
}
|
|
1450
1449
|
recorder.start()
|
|
1451
1450
|
if (voice.settings && voice.settings.vadEngine !== 'amplitude' && voice.sileroVad) {
|
|
1452
|
-
voice.sileroVad.init().catch(() =>
|
|
1451
|
+
voice.sileroVad.init().catch(() => 0)
|
|
1453
1452
|
}
|
|
1454
1453
|
if (voice.settings && voice.settings.streamingWs !== false && voice.streamingWs && voice.streamingWs.isSupported()) {
|
|
1455
1454
|
voice.streamingWs.createStream({
|
|
@@ -1467,7 +1466,7 @@ return rec
|
|
|
1467
1466
|
if (rec) {
|
|
1468
1467
|
teardown(rec)
|
|
1469
1468
|
} else {
|
|
1470
|
-
try { stream.getTracks().forEach((t) => t.stop()) } catch (_) {}
|
|
1469
|
+
try { stream.getTracks().forEach((t) => t.stop()) } catch (_) { 0 }
|
|
1471
1470
|
}
|
|
1472
1471
|
throw err
|
|
1473
1472
|
}
|
|
@@ -1551,10 +1550,10 @@ rec.streamMs = 0
|
|
|
1551
1550
|
if (!rec.closing && !rec.cancelled) {
|
|
1552
1551
|
try {
|
|
1553
1552
|
if (rec.recorder && rec.recorder.state === 'inactive') rec.recorder.start()
|
|
1554
|
-
} catch (e) {
|
|
1553
|
+
} catch (e) { 0 }
|
|
1555
1554
|
}
|
|
1556
1555
|
rec.cutting = false
|
|
1557
|
-
if (rec.cancelled || blob.size < 600) return
|
|
1556
|
+
if (rec.cancelled || blob.size < 600) return
|
|
1558
1557
|
if (rec.wsStream && rec.wsStream.isOpen) {
|
|
1559
1558
|
rec.wsStream.sendBlobChunk(blob)
|
|
1560
1559
|
rec.wsStream.requestInterim()
|
|
@@ -1623,7 +1622,7 @@ if (ww && mode === 'dictation' && !voice.rec) {
|
|
|
1623
1622
|
const t = String(text || '').trim().toLowerCase()
|
|
1624
1623
|
if (t.startsWith(ww)) {
|
|
1625
1624
|
if (voice.browser && typeof voice.browser.abort === 'function') {
|
|
1626
|
-
try { voice.browser.abort() } catch (_) {}
|
|
1625
|
+
try { voice.browser.abort() } catch (_) { 0 }
|
|
1627
1626
|
}
|
|
1628
1627
|
voice.browser = null
|
|
1629
1628
|
voice.caption = ''
|
|
@@ -1673,7 +1672,7 @@ const targetActions = voice.inputActions
|
|
|
1673
1672
|
const targetInput = voice.input
|
|
1674
1673
|
let span = null
|
|
1675
1674
|
if (targetActions && typeof targetActions.captureInsertion === 'function') {
|
|
1676
|
-
try { span = targetActions.captureInsertion() } catch (_) {}
|
|
1675
|
+
try { span = targetActions.captureInsertion() } catch (_) { 0 }
|
|
1677
1676
|
}
|
|
1678
1677
|
const initialDraft = (targetInput && typeof targetInput.draft === 'string') ? targetInput.draft : ''
|
|
1679
1678
|
const targetSession = voice.session || (targetInput && targetInput.session)
|
|
@@ -1741,7 +1740,7 @@ rec.closing = true
|
|
|
1741
1740
|
const stopped = waitStop(rec.recorder)
|
|
1742
1741
|
try {
|
|
1743
1742
|
if (rec.recorder && rec.recorder.state !== 'inactive') rec.recorder.stop()
|
|
1744
|
-
} catch (e) {
|
|
1743
|
+
} catch (e) { 0 }
|
|
1745
1744
|
stopped.then(() => { teardown(rec); voice.rec = null; voice.set({ phase: 'idle', error: '' }) })
|
|
1746
1745
|
}
|
|
1747
1746
|
function stopCurrent() {
|
|
@@ -1788,7 +1787,7 @@ const mode = rec.mode
|
|
|
1788
1787
|
const stopped = waitStop(rec.recorder)
|
|
1789
1788
|
try {
|
|
1790
1789
|
if (rec.recorder && rec.recorder.state !== 'inactive') rec.recorder.stop()
|
|
1791
|
-
} catch (e) {
|
|
1790
|
+
} catch (e) { 0 }
|
|
1792
1791
|
stopped.then(async () => {
|
|
1793
1792
|
if (voice.disposed || rec.cancelled || voice.activeOpId !== opId) {
|
|
1794
1793
|
teardown(rec)
|
|
@@ -1800,15 +1799,15 @@ teardown(rec)
|
|
|
1800
1799
|
if (voice.rec === rec) voice.rec = null
|
|
1801
1800
|
if (voice.disposed || rec.cancelled || voice.activeOpId !== opId) return
|
|
1802
1801
|
if (blob.size < (mode === 'dictation' ? 600 : 1200)) {
|
|
1803
|
-
if (mode === 'dictation') { try { await dictationQueue } catch (_) {} }
|
|
1802
|
+
if (mode === 'dictation') { try { await dictationQueue } catch (_) { 0 } }
|
|
1804
1803
|
voice.set({ phase: 'idle' })
|
|
1805
1804
|
return
|
|
1806
1805
|
}
|
|
1807
1806
|
if (voice.lastNote && voice.lastNote.url) {
|
|
1808
|
-
try { URL.revokeObjectURL(voice.lastNote.url) } catch (e) {}
|
|
1807
|
+
try { URL.revokeObjectURL(voice.lastNote.url) } catch (e) { 0 }
|
|
1809
1808
|
}
|
|
1810
1809
|
let noteUrl = ''
|
|
1811
|
-
try { noteUrl = URL.createObjectURL(blob) } catch (e) {}
|
|
1810
|
+
try { noteUrl = URL.createObjectURL(blob) } catch (e) { 0 }
|
|
1812
1811
|
voice.lastNote = { blob, url: noteUrl, mime: rec.mime, text: '' }
|
|
1813
1812
|
voice.set({ phase: 'processing' })
|
|
1814
1813
|
const q = { clipping: Boolean(rec.hasClipped), lowVolume: Boolean(rec.hasLowVolume) }
|
|
@@ -1850,7 +1849,7 @@ try {
|
|
|
1850
1849
|
const pRes = await apiClient.polish({ text })
|
|
1851
1850
|
const pData = await pRes.json()
|
|
1852
1851
|
if (pData && pData.text) polishedText = pData.text
|
|
1853
|
-
} catch (_) {}
|
|
1852
|
+
} catch (_) { 0 }
|
|
1854
1853
|
}
|
|
1855
1854
|
const autoMs = Number(voice.settings.autoSendMs) || 4000
|
|
1856
1855
|
const pendingState = usePreview
|
|
@@ -1870,7 +1869,7 @@ voice.set({ phase: 'error', error: String(e && e.message ? e.message : e) })
|
|
|
1870
1869
|
}
|
|
1871
1870
|
if (mode === 'dictation') {
|
|
1872
1871
|
dictationQueue = dictationQueue.then(processTail)
|
|
1873
|
-
try { await dictationQueue } catch (_) {}
|
|
1872
|
+
try { await dictationQueue } catch (_) { 0 }
|
|
1874
1873
|
} else {
|
|
1875
1874
|
await processTail()
|
|
1876
1875
|
}
|
|
@@ -2026,10 +2025,10 @@ hold.mode = mode
|
|
|
2026
2025
|
hold.startedAt = Date.now()
|
|
2027
2026
|
hold.active = false
|
|
2028
2027
|
if (pointerEvent?.target?.setPointerCapture && pointerEvent.pointerId !== undefined) {
|
|
2029
|
-
try { pointerEvent.target.setPointerCapture(pointerEvent.pointerId) } catch (e) {}
|
|
2028
|
+
try { pointerEvent.target.setPointerCapture(pointerEvent.pointerId) } catch (e) { 0 }
|
|
2030
2029
|
}
|
|
2031
2030
|
if (typeof window !== 'undefined') {
|
|
2032
|
-
if (activePointerCleanup) { try { activePointerCleanup() } catch (e) {} }
|
|
2031
|
+
if (activePointerCleanup) { try { activePointerCleanup() } catch (e) { 0 } }
|
|
2033
2032
|
const onUp = () => endHold(false)
|
|
2034
2033
|
const onCancel = () => endHold(true)
|
|
2035
2034
|
window.addEventListener('pointerup', onUp, { once: true })
|
|
@@ -2051,7 +2050,7 @@ voice.notify()
|
|
|
2051
2050
|
}, HOLD_THRESHOLD_MS)
|
|
2052
2051
|
}
|
|
2053
2052
|
function endHold(cancelled) {
|
|
2054
|
-
if (activePointerCleanup) { try { activePointerCleanup() } catch (e) {} }
|
|
2053
|
+
if (activePointerCleanup) { try { activePointerCleanup() } catch (e) { 0 } }
|
|
2055
2054
|
if (!hold.armed) return
|
|
2056
2055
|
const wasHeld = hold.active
|
|
2057
2056
|
hold.armed = false
|
|
@@ -2066,11 +2065,11 @@ stopCurrent()
|
|
|
2066
2065
|
let activeHotkeyCleanup = null
|
|
2067
2066
|
function clearGlobalHotkey() {
|
|
2068
2067
|
if (typeof activeHotkeyCleanup === 'function') {
|
|
2069
|
-
try { activeHotkeyCleanup() } catch (_) {
|
|
2068
|
+
try { activeHotkeyCleanup() } catch (_) { 0 }
|
|
2070
2069
|
activeHotkeyCleanup = null
|
|
2071
2070
|
}
|
|
2072
2071
|
if (typeof window !== 'undefined' && typeof window.__dsh_voice_hotkey_cleanup === 'function') {
|
|
2073
|
-
try { window.__dsh_voice_hotkey_cleanup() } catch (_) {
|
|
2072
|
+
try { window.__dsh_voice_hotkey_cleanup() } catch (_) { 0 }
|
|
2074
2073
|
window.__dsh_voice_hotkey_cleanup = null
|
|
2075
2074
|
}
|
|
2076
2075
|
}
|
|
@@ -2167,7 +2166,7 @@ const target = pending.target || voice._activeTarget
|
|
|
2167
2166
|
const actions = (target && target.actions) || voice.inputActions
|
|
2168
2167
|
if (pending.rawText !== undefined && pending.initialDraft !== undefined) {
|
|
2169
2168
|
if (actions && typeof actions.setDraft === 'function') {
|
|
2170
|
-
try { actions.setDraft(pending.initialDraft) } catch (_) {}
|
|
2169
|
+
try { actions.setDraft(pending.initialDraft) } catch (_) { 0 }
|
|
2171
2170
|
}
|
|
2172
2171
|
}
|
|
2173
2172
|
voice.pending = null
|
|
@@ -2188,7 +2187,7 @@ const full = initial
|
|
|
2188
2187
|
? (initial.endsWith(' ') || initial.endsWith('\n') ? (initial + textToInsert) : (initial + ' ' + textToInsert))
|
|
2189
2188
|
: textToInsert
|
|
2190
2189
|
if (actions && typeof actions.setDraft === 'function') {
|
|
2191
|
-
try { actions.setDraft(full) } catch (_) {}
|
|
2190
|
+
try { actions.setDraft(full) } catch (_) { 0 }
|
|
2192
2191
|
}
|
|
2193
2192
|
}
|
|
2194
2193
|
voice.pending = null
|
|
@@ -2217,10 +2216,10 @@ const full = initial
|
|
|
2217
2216
|
? (initial.endsWith(' ') || initial.endsWith('\n') ? (initial + textToSend) : (initial + ' ' + textToSend))
|
|
2218
2217
|
: textToSend
|
|
2219
2218
|
if (actions && typeof actions.setDraft === 'function') {
|
|
2220
|
-
try { actions.setDraft(full) } catch (_) {}
|
|
2219
|
+
try { actions.setDraft(full) } catch (_) { 0 }
|
|
2221
2220
|
}
|
|
2222
2221
|
if (actions && typeof actions.submit === 'function') {
|
|
2223
|
-
try { actions.submit() } catch (_) {}
|
|
2222
|
+
try { actions.submit() } catch (_) { 0 }
|
|
2224
2223
|
}
|
|
2225
2224
|
} else {
|
|
2226
2225
|
if (voice.settings.polishSend) {
|
|
@@ -2282,7 +2281,7 @@ title: isPlaying ? t('pause') : t('play'),
|
|
|
2282
2281
|
onClick: () => {
|
|
2283
2282
|
const el = audioRef.current
|
|
2284
2283
|
if (!el) return
|
|
2285
|
-
if (el.paused) { el.play().catch(() =>
|
|
2284
|
+
if (el.paused) { el.play().catch(() => 0); setIsPlaying(true) }
|
|
2286
2285
|
else { el.pause(); setIsPlaying(false) }
|
|
2287
2286
|
},
|
|
2288
2287
|
}, isPlaying ? pauseIcon() : playIcon()),
|
|
@@ -2428,7 +2427,7 @@ if (pick) {
|
|
|
2428
2427
|
_accentColorCache = { color: pick, expires: now + 1000 }
|
|
2429
2428
|
return pick
|
|
2430
2429
|
}
|
|
2431
|
-
} catch (noTheme) {
|
|
2430
|
+
} catch (noTheme) { 0 }
|
|
2432
2431
|
return fallback || voice.waveColor || 'currentColor'
|
|
2433
2432
|
}
|
|
2434
2433
|
function softColor(fallback) {
|
|
@@ -2442,7 +2441,7 @@ if (pick) {
|
|
|
2442
2441
|
_softColorCache = { color: pick, expires: now + 1000 }
|
|
2443
2442
|
return pick
|
|
2444
2443
|
}
|
|
2445
|
-
} catch (noTheme) {
|
|
2444
|
+
} catch (noTheme) { 0 }
|
|
2446
2445
|
return fallback || voice.waveColor || 'currentColor'
|
|
2447
2446
|
}
|
|
2448
2447
|
function drawLiquidWave(g, w, h, levels, color, time) {
|
|
@@ -2626,7 +2625,7 @@ try { voice.waveColor = getComputedStyle(canvas).color || 'currentColor' } catch
|
|
|
2626
2625
|
}
|
|
2627
2626
|
let drawColor = voice.waveColor
|
|
2628
2627
|
if (voice.audioQuality && (voice.audioQuality.clipping || voice.audioQuality.lowVolume)) {
|
|
2629
|
-
try { drawColor = getComputedStyle(canvas).color || voice.waveColor } catch (_) {}
|
|
2628
|
+
try { drawColor = getComputedStyle(canvas).color || voice.waveColor } catch (_) { 0 }
|
|
2630
2629
|
}
|
|
2631
2630
|
const levels = voice.levels
|
|
2632
2631
|
const style = (voice.settings && voice.settings.visualizerStyle) || 'liquid-wave'
|
|
@@ -2689,7 +2688,7 @@ title: isPlaying ? t('pause') : t('play'),
|
|
|
2689
2688
|
onClick: () => {
|
|
2690
2689
|
const el = audioRef.current
|
|
2691
2690
|
if (!el) return
|
|
2692
|
-
if (el.paused) { el.play().catch(() =>
|
|
2691
|
+
if (el.paused) { el.play().catch(() => 0); setIsPlaying(true) }
|
|
2693
2692
|
else { el.pause(); setIsPlaying(false) }
|
|
2694
2693
|
},
|
|
2695
2694
|
}, isPlaying ? pauseIcon() : playIcon()),
|
|
@@ -2820,7 +2819,7 @@ title: isPlaying ? t('pause') : t('play'),
|
|
|
2820
2819
|
onClick: () => {
|
|
2821
2820
|
const el = audioRef.current
|
|
2822
2821
|
if (!el) return
|
|
2823
|
-
if (el.paused) { el.play().catch(() =>
|
|
2822
|
+
if (el.paused) { el.play().catch(() => 0); setIsPlaying(true) }
|
|
2824
2823
|
else { el.pause(); setIsPlaying(false) }
|
|
2825
2824
|
},
|
|
2826
2825
|
}, isPlaying ? pauseIcon() : playIcon()),
|
|
@@ -2927,7 +2926,7 @@ showMessageButton: data ? data.showMessageButton !== false : true,
|
|
|
2927
2926
|
})
|
|
2928
2927
|
voice.notify()
|
|
2929
2928
|
})
|
|
2930
|
-
.catch(() =>
|
|
2929
|
+
.catch(() => 0)
|
|
2931
2930
|
}
|
|
2932
2931
|
reload()
|
|
2933
2932
|
window.addEventListener('dsh-voice:settings-saved', reload)
|
|
@@ -2956,7 +2955,7 @@ if (typeof offDock === 'function') offDock()
|
|
|
2956
2955
|
function cloneSettingsObj(obj) {
|
|
2957
2956
|
if (!obj || typeof obj !== 'object') return obj
|
|
2958
2957
|
if (typeof structuredClone === 'function') {
|
|
2959
|
-
try { return structuredClone(obj) } catch (_) {}
|
|
2958
|
+
try { return structuredClone(obj) } catch (_) { 0 }
|
|
2960
2959
|
}
|
|
2961
2960
|
try { return JSON.parse(JSON.stringify(obj)) } catch (_) { return Object.assign({}, obj) }
|
|
2962
2961
|
}
|
|
@@ -2986,7 +2985,7 @@ function createSettingsDraftStore(initialSaved = null) {
|
|
|
2986
2985
|
let savedConfig = initialSaved ? cloneSettingsObj(initialSaved) : null
|
|
2987
2986
|
let draftConfig = initialSaved ? cloneSettingsObj(initialSaved) : null
|
|
2988
2987
|
const listeners = new Set()
|
|
2989
|
-
const notify = () => { for (const fn of listeners) { try { fn() } catch (_) {} } }
|
|
2988
|
+
const notify = () => { for (const fn of listeners) { try { fn() } catch (_) { 0 } } }
|
|
2990
2989
|
return {
|
|
2991
2990
|
getState() {
|
|
2992
2991
|
const { isValid, errors } = validateSettingsDraft(draftConfig)
|
|
@@ -3707,7 +3706,7 @@ apiClient.getSensevoiceInstaller()
|
|
|
3707
3706
|
setSensevoiceState(d)
|
|
3708
3707
|
setInstallingSensevoice(!!(d && d.installing))
|
|
3709
3708
|
})
|
|
3710
|
-
.catch(() =>
|
|
3709
|
+
.catch(() => 0)
|
|
3711
3710
|
}
|
|
3712
3711
|
React.useEffect(() => {
|
|
3713
3712
|
fetchSensevoice()
|
|
@@ -3755,7 +3754,7 @@ stream = await navigator.mediaDevices.getUserMedia({ audio })
|
|
|
3755
3754
|
const AC = typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : null)
|
|
3756
3755
|
if (!AC) throw new Error(t('audioContextUnsupported'))
|
|
3757
3756
|
audioCtx = new AC()
|
|
3758
|
-
if (audioCtx.state === 'suspended') await audioCtx.resume().catch(() =>
|
|
3757
|
+
if (audioCtx.state === 'suspended') await audioCtx.resume().catch(() => 0)
|
|
3759
3758
|
const src = audioCtx.createMediaStreamSource(stream)
|
|
3760
3759
|
const analyser = audioCtx.createAnalyser()
|
|
3761
3760
|
analyser.fftSize = 512
|
|
@@ -3793,10 +3792,10 @@ setTimeout(() => setCalibrateMsg(''), 5000)
|
|
|
3793
3792
|
if (typeof setErr === 'function') setErr(String(e && e.message ? e.message : e))
|
|
3794
3793
|
} finally {
|
|
3795
3794
|
if (stream) {
|
|
3796
|
-
try { stream.getTracks().forEach((t) => t.stop()) } catch (e) {}
|
|
3795
|
+
try { stream.getTracks().forEach((t) => t.stop()) } catch (e) { 0 }
|
|
3797
3796
|
}
|
|
3798
3797
|
if (audioCtx) {
|
|
3799
|
-
try { audioCtx.close() } catch (e) {}
|
|
3798
|
+
try { audioCtx.close() } catch (e) { 0 }
|
|
3800
3799
|
}
|
|
3801
3800
|
setCalibrating(false)
|
|
3802
3801
|
}
|
|
@@ -3805,8 +3804,8 @@ const toggleTestMic = async () => {
|
|
|
3805
3804
|
if (testingMic) {
|
|
3806
3805
|
if (testRef.current) {
|
|
3807
3806
|
testRef.current.active = false
|
|
3808
|
-
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) {
|
|
3809
|
-
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) {
|
|
3807
|
+
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) { 0 }
|
|
3808
|
+
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) { 0 } }
|
|
3810
3809
|
testRef.current = null
|
|
3811
3810
|
}
|
|
3812
3811
|
setTestingMic(false)
|
|
@@ -3821,7 +3820,7 @@ const stream = await navigator.mediaDevices.getUserMedia({ audio })
|
|
|
3821
3820
|
const AC = typeof AudioContext !== 'undefined' ? AudioContext : (typeof webkitAudioContext !== 'undefined' ? webkitAudioContext : null)
|
|
3822
3821
|
if (!AC) return
|
|
3823
3822
|
const audioCtx = new AC()
|
|
3824
|
-
if (audioCtx.state === 'suspended') await audioCtx.resume().catch(() =>
|
|
3823
|
+
if (audioCtx.state === 'suspended') await audioCtx.resume().catch(() => 0)
|
|
3825
3824
|
const src = audioCtx.createMediaStreamSource(stream)
|
|
3826
3825
|
let lastNode = src
|
|
3827
3826
|
try {
|
|
@@ -3831,7 +3830,7 @@ filter.frequency.value = 80
|
|
|
3831
3830
|
filter.Q.value = 0.707
|
|
3832
3831
|
src.connect(filter)
|
|
3833
3832
|
lastNode = filter
|
|
3834
|
-
} catch (e) {
|
|
3833
|
+
} catch (e) { 0 }
|
|
3835
3834
|
const analyser = audioCtx.createAnalyser()
|
|
3836
3835
|
analyser.fftSize = 128
|
|
3837
3836
|
lastNode.connect(analyser)
|
|
@@ -3856,8 +3855,8 @@ React.useEffect(() => {
|
|
|
3856
3855
|
return () => {
|
|
3857
3856
|
if (testRef.current) {
|
|
3858
3857
|
testRef.current.active = false
|
|
3859
|
-
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) {
|
|
3860
|
-
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) {
|
|
3858
|
+
try { testRef.current.stream.getTracks().forEach((t) => t.stop()) } catch (e) { 0 }
|
|
3859
|
+
if (testRef.current.audioCtx) { try { testRef.current.audioCtx.close() } catch (e) { 0 } }
|
|
3861
3860
|
testRef.current = null
|
|
3862
3861
|
}
|
|
3863
3862
|
}
|
|
@@ -4214,7 +4213,7 @@ setDraft((curr) => curr || deepClone(data.config))
|
|
|
4214
4213
|
if (data.config.wizardCompleted !== true) setShowWizard(true)
|
|
4215
4214
|
}
|
|
4216
4215
|
})
|
|
4217
|
-
.catch(() =>
|
|
4216
|
+
.catch(() => 0)
|
|
4218
4217
|
.finally(() => {
|
|
4219
4218
|
if (alive) setConfigLoading(false)
|
|
4220
4219
|
})
|
|
@@ -4254,7 +4253,7 @@ React.useEffect(() => {
|
|
|
4254
4253
|
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) return
|
|
4255
4254
|
navigator.mediaDevices.enumerateDevices()
|
|
4256
4255
|
.then((list) => setDevices(list.filter((d) => d.kind === 'audioinput')))
|
|
4257
|
-
.catch(() =>
|
|
4256
|
+
.catch(() => 0)
|
|
4258
4257
|
}, [])
|
|
4259
4258
|
const ready = !!serverConfig || (!!snap && snap.status === 'ready')
|
|
4260
4259
|
const value = (snap && snap.status === 'ready' && snap.value) ? snap.value : (serverConfig || {})
|
|
@@ -4271,13 +4270,13 @@ ctx.configForms.describe().load()
|
|
|
4271
4270
|
} else if (ctx.settingsScope && typeof ctx.settingsScope.describe === 'function') {
|
|
4272
4271
|
ctx.settingsScope.describe().load()
|
|
4273
4272
|
}
|
|
4274
|
-
} catch (e) {
|
|
4273
|
+
} catch (e) { 0 }
|
|
4275
4274
|
}, 1000)
|
|
4276
4275
|
return () => clearInterval(timer)
|
|
4277
4276
|
}, [ready])
|
|
4278
4277
|
const deepClone = (obj) => {
|
|
4279
4278
|
if (typeof structuredClone === 'function') {
|
|
4280
|
-
try { return structuredClone(obj) } catch (e) {
|
|
4279
|
+
try { return structuredClone(obj) } catch (e) { 0 }
|
|
4281
4280
|
}
|
|
4282
4281
|
try { return JSON.parse(JSON.stringify(obj)) } catch (e) { return Object.assign({}, obj) }
|
|
4283
4282
|
}
|
|
@@ -4421,8 +4420,7 @@ if (httpOk && scope && typeof scope.set === 'function') {
|
|
|
4421
4420
|
for (const k of Object.keys(draft)) {
|
|
4422
4421
|
try {
|
|
4423
4422
|
await scope.set(k, draft[k])
|
|
4424
|
-
} catch (e) {
|
|
4425
|
-
}
|
|
4423
|
+
} catch (e) { 0 }
|
|
4426
4424
|
}
|
|
4427
4425
|
}
|
|
4428
4426
|
if (!httpOk) {
|
|
@@ -4463,7 +4461,7 @@ showDictationModeButton: d.showDictationModeButton !== false,
|
|
|
4463
4461
|
showDictationButton: d.showDictationButton !== false,
|
|
4464
4462
|
showMessageButton: d.showMessageButton !== false,
|
|
4465
4463
|
})
|
|
4466
|
-
try { window.dispatchEvent(new CustomEvent('dsh-voice:settings-saved')) } catch (noEvents) {
|
|
4464
|
+
try { window.dispatchEvent(new CustomEvent('dsh-voice:settings-saved')) } catch (noEvents) { 0 }
|
|
4467
4465
|
voice.notify(); setSaved(true); setJargonInput(null)
|
|
4468
4466
|
setTimeout(() => setSaved(false), 2000)
|
|
4469
4467
|
fetchStatus()
|
|
@@ -4749,7 +4747,7 @@ setMicPermission(p.state)
|
|
|
4749
4747
|
p.onchange = () => setMicPermission(p.state)
|
|
4750
4748
|
}
|
|
4751
4749
|
})
|
|
4752
|
-
.catch(() =>
|
|
4750
|
+
.catch(() => 0)
|
|
4753
4751
|
}
|
|
4754
4752
|
}, [])
|
|
4755
4753
|
const refreshDevices = () => {
|
|
@@ -4759,7 +4757,7 @@ navigator.mediaDevices.enumerateDevices()
|
|
|
4759
4757
|
const audioInputs = list.filter((d) => d.kind === 'audioinput')
|
|
4760
4758
|
setDevices(audioInputs)
|
|
4761
4759
|
})
|
|
4762
|
-
.catch(() =>
|
|
4760
|
+
.catch(() => 0)
|
|
4763
4761
|
}
|
|
4764
4762
|
React.useEffect(() => {
|
|
4765
4763
|
refreshDevices()
|
|
@@ -4770,11 +4768,11 @@ cancelAnimationFrame(animFrameRef.current)
|
|
|
4770
4768
|
animFrameRef.current = null
|
|
4771
4769
|
}
|
|
4772
4770
|
if (signalStreamRef.current) {
|
|
4773
|
-
try { signalStreamRef.current.getTracks().forEach((trk) => trk.stop()) } catch (_) {}
|
|
4771
|
+
try { signalStreamRef.current.getTracks().forEach((trk) => trk.stop()) } catch (_) { 0 }
|
|
4774
4772
|
signalStreamRef.current = null
|
|
4775
4773
|
}
|
|
4776
4774
|
if (audioCtxRef.current) {
|
|
4777
|
-
try { audioCtxRef.current.close() } catch (_) {}
|
|
4775
|
+
try { audioCtxRef.current.close() } catch (_) { 0 }
|
|
4778
4776
|
audioCtxRef.current = null
|
|
4779
4777
|
}
|
|
4780
4778
|
setSignalTesting(false)
|
|
@@ -4810,7 +4808,7 @@ const AC = typeof AudioContext !== 'undefined' ? AudioContext
|
|
|
4810
4808
|
if (!AC) return
|
|
4811
4809
|
const actx = new AC()
|
|
4812
4810
|
audioCtxRef.current = actx
|
|
4813
|
-
if (actx.state === 'suspended') { actx.resume().catch(() =>
|
|
4811
|
+
if (actx.state === 'suspended') { actx.resume().catch(() => 0) }
|
|
4814
4812
|
const src = actx.createMediaStreamSource(stream)
|
|
4815
4813
|
const analyser = actx.createAnalyser()
|
|
4816
4814
|
analyser.fftSize = 128
|
|
@@ -4874,7 +4872,7 @@ if (recorder.state !== 'inactive') recorder.stop()
|
|
|
4874
4872
|
}
|
|
4875
4873
|
}, 1000)
|
|
4876
4874
|
await new Promise((resolve) => recorder.addEventListener('stop', resolve, { once: true }))
|
|
4877
|
-
try { testStream.getTracks().forEach((trk) => trk.stop()) } catch (_) {}
|
|
4875
|
+
try { testStream.getTracks().forEach((trk) => trk.stop()) } catch (_) { 0 }
|
|
4878
4876
|
const blob = new Blob(chunks, { type: mime || 'audio/webm' })
|
|
4879
4877
|
if (blob.size < 400) {
|
|
4880
4878
|
setTestError(t('wizardTestEmpty'))
|
|
@@ -4912,7 +4910,7 @@ setTestError(t('wizardTestEmpty'))
|
|
|
4912
4910
|
setTestError(String(err && err.message ? err.message : err))
|
|
4913
4911
|
} finally {
|
|
4914
4912
|
if (testStream) {
|
|
4915
|
-
try { testStream.getTracks().forEach((trk) => trk.stop()) } catch (_) {}
|
|
4913
|
+
try { testStream.getTracks().forEach((trk) => trk.stop()) } catch (_) { 0 }
|
|
4916
4914
|
}
|
|
4917
4915
|
setTestingStt(false)
|
|
4918
4916
|
}
|
package/lib/config-routes.js
CHANGED
|
@@ -157,7 +157,9 @@ export function registerConfigRoutes(ctx, {
|
|
|
157
157
|
let newRev
|
|
158
158
|
try {
|
|
159
159
|
newRev = settingsService?.describe?.()?.find?.((r) => r.ns === NS)?.revision
|
|
160
|
-
} catch {
|
|
160
|
+
} catch (revErr) {
|
|
161
|
+
bestEffort('readRevision', () => { throw revErr })
|
|
162
|
+
}
|
|
161
163
|
writeJson(res, 200, { ok: true, config: live(), revision: newRev, sessionToken: getVoiceSessionToken() })
|
|
162
164
|
} catch (err) {
|
|
163
165
|
writeJson(res, 500, { ok: false, error: { code: 'save', message: String(err?.message || err) } })
|
package/lib/http-util.js
CHANGED
|
@@ -18,9 +18,6 @@ export function getVoiceSessionToken() {
|
|
|
18
18
|
return sessionSecret
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function setVoiceSessionToken(t) {
|
|
22
|
-
sessionSecret = String(t || '')
|
|
23
|
-
}
|
|
24
21
|
|
|
25
22
|
export function rotateVoiceSessionToken() {
|
|
26
23
|
sessionSecret = randomBytes(24).toString('hex')
|
package/lib/index.js
CHANGED
|
@@ -13,10 +13,7 @@ export const name = '@goodandready/dsh-voice'
|
|
|
13
13
|
export const NS = 'dsh-voice'
|
|
14
14
|
export const inject = ['tools', 'credentials', 'webServer', 'shell', 'settings', 'llm']
|
|
15
15
|
|
|
16
|
-
function makeVolatile(schema) {
|
|
17
|
-
return schemaMakeVolatile(schema)
|
|
18
|
-
}
|
|
19
|
-
|
|
16
|
+
function makeVolatile(schema) { return schemaMakeVolatile(schema) }
|
|
20
17
|
export const Config = typeof z.number().volatile === 'function'
|
|
21
18
|
? makeVolatile(BaseConfig)
|
|
22
19
|
: BaseConfig
|
|
@@ -35,9 +32,7 @@ export function apply(ctx, baseConfig) {
|
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
const daemons = createServerDaemons({ live, ctx })
|
|
38
|
-
function triggerAutostart() {
|
|
39
|
-
daemons.triggerAutostart()
|
|
40
|
-
}
|
|
35
|
+
function triggerAutostart() { daemons.triggerAutostart() }
|
|
41
36
|
|
|
42
37
|
ctx.inject(['settings'], (sctx) => {
|
|
43
38
|
settingsService = sctx.settings
|
|
@@ -88,7 +83,9 @@ export function apply(ctx, baseConfig) {
|
|
|
88
83
|
if (typeof scope.replace === 'function') await scope.replace(merged)
|
|
89
84
|
else if (typeof scope.patch === 'function') await scope.patch(merged)
|
|
90
85
|
else if (typeof scope.set === 'function') {
|
|
91
|
-
for (const [k, v] of Object.entries(merged))
|
|
86
|
+
for (const [k, v] of Object.entries(merged)) {
|
|
87
|
+
await scope.set(k, v).catch((err) => ctx.logger?.warn?.(`[dsh-voice] save ${k}: ${err?.message || err}`))
|
|
88
|
+
}
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
91
|
},
|
package/lib/local-daemon.js
CHANGED
|
@@ -84,12 +84,16 @@ export function createLocalDaemons({ live, ctx }) {
|
|
|
84
84
|
const out = child.readOutput()
|
|
85
85
|
if (out && out.stderr) detail = String(out.stderr).trim()
|
|
86
86
|
else if (out && out.stdout) detail = String(out.stdout).trim()
|
|
87
|
-
} catch (
|
|
87
|
+
} catch (err) {
|
|
88
|
+
if (ctx?.logger?.debug) ctx.logger.debug('[dsh-voice:local-daemon] error reading child.readOutput:', err?.message || err)
|
|
89
|
+
}
|
|
88
90
|
} else if (typeof child.read === 'function') {
|
|
89
91
|
try {
|
|
90
92
|
const out = child.read()
|
|
91
93
|
if (out && out.stderr) detail = String(out.stderr).trim()
|
|
92
|
-
} catch (
|
|
94
|
+
} catch (err) {
|
|
95
|
+
if (ctx?.logger?.debug) ctx.logger.debug('[dsh-voice:local-daemon] error reading child.read:', err?.message || err)
|
|
96
|
+
}
|
|
93
97
|
}
|
|
94
98
|
if (typeof child.result === 'function') {
|
|
95
99
|
try {
|
|
@@ -139,12 +143,16 @@ export function createLocalDaemons({ live, ctx }) {
|
|
|
139
143
|
const out = child.readOutput()
|
|
140
144
|
if (out && out.stderr) detail = String(out.stderr).trim()
|
|
141
145
|
else if (out && out.stdout) detail = String(out.stdout).trim()
|
|
142
|
-
} catch (
|
|
146
|
+
} catch (err) {
|
|
147
|
+
if (ctx?.logger?.debug) ctx.logger.debug('[dsh-voice:local-daemon] error reading child.readOutput:', err?.message || err)
|
|
148
|
+
}
|
|
143
149
|
} else if (typeof child.read === 'function') {
|
|
144
150
|
try {
|
|
145
151
|
const out = child.read()
|
|
146
152
|
if (out && out.stderr) detail = String(out.stderr).trim()
|
|
147
|
-
} catch (
|
|
153
|
+
} catch (err) {
|
|
154
|
+
if (ctx?.logger?.debug) ctx.logger.debug('[dsh-voice:local-daemon] error reading child.read:', err?.message || err)
|
|
155
|
+
}
|
|
148
156
|
}
|
|
149
157
|
let code = child.exitCode
|
|
150
158
|
const isTerminal = (child.status && child.status !== 'running') || (code !== null && code !== undefined)
|
|
@@ -269,7 +277,9 @@ export function createLocalDaemons({ live, ctx }) {
|
|
|
269
277
|
if (r.exitCode !== undefined && r.exitCode !== null) code = r.exitCode
|
|
270
278
|
if (r.stderr) detail = String(r.stderr).trim()
|
|
271
279
|
}
|
|
272
|
-
} catch (
|
|
280
|
+
} catch (err) {
|
|
281
|
+
if (ctx?.logger?.debug) ctx.logger.debug('[dsh-voice:local-daemon] error awaiting sensevoiceChild.result:', err?.message || err)
|
|
282
|
+
}
|
|
273
283
|
} else if (sensevoiceChild.result && typeof sensevoiceChild.result === 'object') {
|
|
274
284
|
code = sensevoiceChild.result.exitCode ?? code
|
|
275
285
|
if (sensevoiceChild.result.stderr) detail = String(sensevoiceChild.result.stderr).trim()
|
|
@@ -307,12 +317,16 @@ export function createLocalDaemons({ live, ctx }) {
|
|
|
307
317
|
const out = sensevoiceChild.readOutput()
|
|
308
318
|
if (out && out.stderr) detail = String(out.stderr).trim()
|
|
309
319
|
else if (out && out.stdout) detail = String(out.stdout).trim()
|
|
310
|
-
} catch (
|
|
320
|
+
} catch (err) {
|
|
321
|
+
if (ctx?.logger?.debug) ctx.logger.debug('[dsh-voice:local-daemon] error reading sensevoice readOutput:', err?.message || err)
|
|
322
|
+
}
|
|
311
323
|
} else if (typeof sensevoiceChild.read === 'function') {
|
|
312
324
|
try {
|
|
313
325
|
const out = sensevoiceChild.read()
|
|
314
326
|
if (out && out.stderr) detail = String(out.stderr).trim()
|
|
315
|
-
} catch (
|
|
327
|
+
} catch (err) {
|
|
328
|
+
if (ctx?.logger?.debug) ctx.logger.debug('[dsh-voice:local-daemon] error reading sensevoice read:', err?.message || err)
|
|
329
|
+
}
|
|
316
330
|
}
|
|
317
331
|
let code = sensevoiceChild.exitCode
|
|
318
332
|
const isTerminal = (sensevoiceChild.status && sensevoiceChild.status !== 'running') || (code !== null && code !== undefined)
|
|
@@ -267,7 +267,9 @@ export async function startSensevoiceInstall(ctx, cfg, updateConfigFn, startSens
|
|
|
267
267
|
installerState.step = 'extracting'
|
|
268
268
|
installerState.progress = 95
|
|
269
269
|
await extractTarBz2(archivePath, modelDir)
|
|
270
|
-
await unlink(archivePath).catch(() => {
|
|
270
|
+
await unlink(archivePath).catch((err) => {
|
|
271
|
+
ctx.logger?.debug?.(`[dsh-voice] failed to unlink temporary archive ${archivePath}: ${err?.message || err}`)
|
|
272
|
+
})
|
|
271
273
|
|
|
272
274
|
let modelFile = null
|
|
273
275
|
if (targetModel === 'whisper-turbo') {
|
|
@@ -297,7 +299,9 @@ export async function startSensevoiceInstall(ctx, cfg, updateConfigFn, startSens
|
|
|
297
299
|
|
|
298
300
|
return { ok: true, modelType: targetModel, modelPath: modelFile }
|
|
299
301
|
} catch (err) {
|
|
300
|
-
await unlink(archivePath).catch(() => {
|
|
302
|
+
await unlink(archivePath).catch((err) => {
|
|
303
|
+
ctx.logger?.debug?.(`[dsh-voice] failed to unlink temporary archive ${archivePath}: ${err?.message || err}`)
|
|
304
|
+
})
|
|
301
305
|
installerState.installing = false
|
|
302
306
|
installerState.error = String(err?.message || err)
|
|
303
307
|
installerState.step = 'failed'
|
package/lib/updater.js
CHANGED
|
@@ -287,7 +287,8 @@ export function checkProfileLock(profileDir) {
|
|
|
287
287
|
return { locked: true, pid: null, error: err?.code || 'EUNKNOWN' };
|
|
288
288
|
}
|
|
289
289
|
const pid = readLockPid(lockPath);
|
|
290
|
-
|
|
290
|
+
const alive = pid ? isProcessAlive(pid) : null;
|
|
291
|
+
return { locked: true, pid, alive };
|
|
291
292
|
}
|
|
292
293
|
|
|
293
294
|
export function formatLockDiagnostic(lockStatus) {
|
|
@@ -296,7 +297,12 @@ export function formatLockDiagnostic(lockStatus) {
|
|
|
296
297
|
return `Profile lock check failed with error ${lockStatus.error}. Filesystem inspection required (do not remove lockfile).`;
|
|
297
298
|
}
|
|
298
299
|
if (lockStatus.pid) {
|
|
299
|
-
|
|
300
|
+
const aliveSuffix = lockStatus.alive === true
|
|
301
|
+
? ' (process is running)'
|
|
302
|
+
: lockStatus.alive === false
|
|
303
|
+
? ' (process is not running)'
|
|
304
|
+
: '';
|
|
305
|
+
return `Profile is locked by process (PID ${lockStatus.pid}${aliveSuffix}). Follow documented controlled operator recovery procedure if the process terminated abnormally.`;
|
|
300
306
|
}
|
|
301
307
|
return 'Profile is locked by an existing lockfile. Follow documented controlled operator recovery procedure if the process terminated abnormally.';
|
|
302
308
|
}
|
package/lib/ws-framer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Pure Node.js RFC 6455 WebSocket framer & upgrade handler with zero dependencies.
|
|
2
2
|
import crypto from 'node:crypto'
|
|
3
3
|
import { EventEmitter } from 'node:events'
|
|
4
|
+
import { bestEffort } from './best-effort.js'
|
|
4
5
|
|
|
5
6
|
const WS_GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
|
|
6
7
|
|
|
@@ -71,8 +72,8 @@ export class WsConnection extends EventEmitter {
|
|
|
71
72
|
reasonBuf.copy(payload, 2)
|
|
72
73
|
this.socket.write(createWsFrame(payload, 0x08))
|
|
73
74
|
this.socket.end()
|
|
74
|
-
} catch (
|
|
75
|
-
|
|
75
|
+
} catch (closeErr) {
|
|
76
|
+
bestEffort('wsSocketDestroy', () => this.socket.destroy())
|
|
76
77
|
}
|
|
77
78
|
this.readyState = 3
|
|
78
79
|
}
|
|
@@ -121,7 +122,7 @@ export class WsConnection extends EventEmitter {
|
|
|
121
122
|
break
|
|
122
123
|
} else if (opcode === 0x09) { // PING -> PONG
|
|
123
124
|
if (this.readyState === 1 && this.socket.writable) {
|
|
124
|
-
|
|
125
|
+
bestEffort('wsPong', () => this.socket.write(createWsFrame(payload, 0x0a)))
|
|
125
126
|
}
|
|
126
127
|
} else if (opcode === 0x01) { // TEXT
|
|
127
128
|
this.emit('message', payload.toString('utf8'), false)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-voice",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.57",
|
|
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",
|
|
@@ -70,5 +70,13 @@
|
|
|
70
70
|
"@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.2 || ^0.2.0-rc.1",
|
|
71
71
|
"@deepseek-ai/dsh-llm": "^0.1.7-rc.2 || ^0.2.0-rc.1",
|
|
72
72
|
"@deepseek-ai/schemastery": "^3.18.1"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
76
|
+
"@deepseek-ai/dsh-credentials": "^0.1.7-rc.2 || ^0.2.0-rc.1",
|
|
77
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.2 || ^0.2.0-rc.1",
|
|
78
|
+
"@deepseek-ai/dsh-llm": "^0.1.7-rc.2 || ^0.2.0-rc.1",
|
|
79
|
+
"@deepseek-ai/dsh-tools": "^0.1.7-rc.2 || ^0.2.0-rc.1",
|
|
80
|
+
"@deepseek-ai/schemastery": "^3.18.4"
|
|
73
81
|
}
|
|
74
82
|
}
|