Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c4ffe418b5 | |||
| 6cf880506d |
@@ -153,10 +153,11 @@ const vad = useVad({
|
|||||||
void stopRecording(false)
|
void stopRecording(false)
|
||||||
},
|
},
|
||||||
onNoSpeech: () => {
|
onNoSpeech: () => {
|
||||||
// User manually stopped without VAD detecting speech. Toast it; the
|
|
||||||
// stopRecording path below will skip Whisper based on vadSawSpeech.
|
|
||||||
useToastStore().show('No speech detected', 'warning')
|
useToastStore().show('No speech detected', 'warning')
|
||||||
},
|
},
|
||||||
|
onVadError: (msg) => {
|
||||||
|
useToastStore().show(`VAD failed: ${msg}`, 'error')
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Live mic halo. A solid red disc sits behind the mic button and scales
|
// Live mic halo. A solid red disc sits behind the mic button and scales
|
||||||
|
|||||||
@@ -2,13 +2,10 @@ import { ref, readonly } from 'vue'
|
|||||||
import type { MicVAD } from '@ricky0123/vad-web'
|
import type { MicVAD } from '@ricky0123/vad-web'
|
||||||
|
|
||||||
export interface UseVadOptions {
|
export interface UseVadOptions {
|
||||||
/** Called when VAD detects a real speech-end event after the grace period. */
|
|
||||||
onSpeechEnd: () => void
|
onSpeechEnd: () => void
|
||||||
/** Called when stopAndCheck() is invoked but no speech was ever detected. */
|
|
||||||
onNoSpeech: () => void
|
onNoSpeech: () => void
|
||||||
/** Minimum ms between speech-start and speech-end before the end event fires. */
|
onVadError?: (message: string) => void
|
||||||
graceMs?: number
|
graceMs?: number
|
||||||
/** Minimum total recording duration before speech-end can fire. */
|
|
||||||
minRecordingMs?: number
|
minRecordingMs?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,8 +105,8 @@ export function useVad(options: UseVadOptions) {
|
|||||||
await micVad.start()
|
await micVad.start()
|
||||||
loaded.value = true
|
loaded.value = true
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// VAD init failed — the user can still manual-stop. Log for debugging.
|
|
||||||
console.error('VAD init failed:', e)
|
console.error('VAD init failed:', e)
|
||||||
|
options.onVadError?.(e instanceof Error ? e.message : String(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,10 +143,11 @@ def create_app() -> Quart:
|
|||||||
response.headers.setdefault("Referrer-Policy", "strict-origin-when-cross-origin")
|
response.headers.setdefault("Referrer-Policy", "strict-origin-when-cross-origin")
|
||||||
response.headers.setdefault(
|
response.headers.setdefault(
|
||||||
"Content-Security-Policy",
|
"Content-Security-Policy",
|
||||||
"default-src 'self'; script-src 'self' 'unsafe-inline'; "
|
"default-src 'self'; "
|
||||||
|
"script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'; "
|
||||||
"style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; "
|
"style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; "
|
||||||
"connect-src 'self'; font-src 'self' data:; object-src 'none'; "
|
"connect-src 'self'; font-src 'self' data:; object-src 'none'; "
|
||||||
"base-uri 'self'; worker-src 'self';"
|
"base-uri 'self'; worker-src 'self' blob:;"
|
||||||
)
|
)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user