Bump version to 0.5.8 and add silence detection timer for audio processing
Some checks failed
Build and Release / build (x64, ubuntu-latest, linux) (push) Has been skipped
Build and Release / build (arm64, macos-latest, darwin) (push) Has been cancelled
Build and Release / build (x64, macos-latest, darwin) (push) Has been cancelled
Build and Release / build (x64, windows-latest, win32) (push) Has been cancelled
Build and Release / release (push) Has been cancelled
Some checks failed
Build and Release / build (x64, ubuntu-latest, linux) (push) Has been skipped
Build and Release / build (arm64, macos-latest, darwin) (push) Has been cancelled
Build and Release / build (x64, macos-latest, darwin) (push) Has been cancelled
Build and Release / build (x64, windows-latest, win32) (push) Has been cancelled
Build and Release / release (push) Has been cancelled
This commit is contained in:
parent
66dce4415a
commit
2f013b4751
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "cheating-daddy",
|
||||
"productName": "cheating-daddy",
|
||||
"version": "0.5.7",
|
||||
"version": "0.5.8",
|
||||
"description": "cheating daddy",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
@ -281,6 +281,7 @@ async function sendImageMessage(base64Image, prompt) {
|
||||
let audioChunks = [];
|
||||
let lastAudioTime = 0;
|
||||
const SILENCE_THRESHOLD_MS = 1500; // 1.5 seconds of silence
|
||||
let silenceCheckTimer = null;
|
||||
|
||||
async function processAudioChunk(base64Audio, mimeType) {
|
||||
if (!openaiClient) {
|
||||
@ -294,8 +295,20 @@ async function processAudioChunk(base64Audio, mimeType) {
|
||||
audioChunks.push(buffer);
|
||||
lastAudioTime = now;
|
||||
|
||||
// Check for silence (no new audio for SILENCE_THRESHOLD_MS)
|
||||
// This is a simple approach - in production you'd want proper VAD
|
||||
// Clear existing timer
|
||||
if (silenceCheckTimer) {
|
||||
clearTimeout(silenceCheckTimer);
|
||||
}
|
||||
|
||||
// Set timer to check for silence
|
||||
silenceCheckTimer = setTimeout(async () => {
|
||||
const silenceDuration = Date.now() - lastAudioTime;
|
||||
if (silenceDuration >= SILENCE_THRESHOLD_MS && audioChunks.length > 0) {
|
||||
console.log('Silence detected, flushing audio for transcription...');
|
||||
await flushAudioAndTranscribe();
|
||||
}
|
||||
}, SILENCE_THRESHOLD_MS);
|
||||
|
||||
return { success: true, buffering: true };
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user