@istarry/spoon-companion 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/asr.js +6 -3
- package/lib/voice.js +1 -0
- package/package.json +1 -1
- package/plugin.js +4 -10
package/lib/asr.js
CHANGED
|
@@ -149,11 +149,14 @@ export function markCallSession(id, on) {
|
|
|
149
149
|
else callSessions.delete(key)
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* 这个会话现在算不算在通话。
|
|
154
|
+
* **只认客户端那把开关** —— 点了通话才算,点挂断就不算。
|
|
155
|
+
* 音频活动不参与判断:录音可能在页面一打开就在跑,拿它当证据会把普通聊天误判成通话。
|
|
156
|
+
*/
|
|
153
157
|
export function isCallActive(sessionId) {
|
|
154
158
|
if (callGlobal) return true
|
|
155
|
-
|
|
156
|
-
return isVoiceActive()
|
|
159
|
+
return Boolean(sessionId && callSessions.has(String(sessionId)))
|
|
157
160
|
}
|
|
158
161
|
|
|
159
162
|
export function feed(pcm, rate = 16000) {
|
package/lib/voice.js
CHANGED
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import { createHash, randomUUID } from 'node:crypto'
|
|
22
22
|
import * as voicePlugin from './lib/voice.js'
|
|
23
23
|
import { applyAsrRoutes } from './lib/asr-route.js'
|
|
24
|
-
import {
|
|
24
|
+
import { isCallActive, markCallSession, setCallGlobal } from './lib/asr.js'
|
|
25
25
|
import { appendFileSync, readFileSync } from 'node:fs'
|
|
26
26
|
import { homedir } from 'node:os'
|
|
27
27
|
import { join } from 'node:path'
|
|
@@ -504,21 +504,15 @@ export function apply(ctx, config = {}) {
|
|
|
504
504
|
|
|
505
505
|
/**
|
|
506
506
|
* 这个会话现在在不在通话里。
|
|
507
|
-
*
|
|
507
|
+
* **只认客户端那把开关** —— 点了通话才算。不拿"有没有在送音频"当证据:
|
|
508
|
+
* 录音可能在页面一打开就在跑,拿它判断会把普通打字聊天误判成通话。
|
|
508
509
|
*/
|
|
509
510
|
const inCallOf = (context) => {
|
|
510
511
|
try {
|
|
511
512
|
if ((settings.callMode ?? {}).enabled === false) return false
|
|
512
513
|
const session = sessionOf(context)
|
|
513
514
|
if (!session) return false
|
|
514
|
-
|
|
515
|
-
let voiceActive = false
|
|
516
|
-
try {
|
|
517
|
-
voiceActive = isVoiceActive()
|
|
518
|
-
} catch {
|
|
519
|
-
voiceActive = false
|
|
520
|
-
}
|
|
521
|
-
return voiceActive || callGlobal || Boolean(id && callSessions.has(id))
|
|
515
|
+
return isCallActive(String(session.id ?? ''))
|
|
522
516
|
} catch {
|
|
523
517
|
return false
|
|
524
518
|
}
|