@adminforth/agent 1.41.2 → 1.41.3
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/build.log +2 -2
- package/custom/composables/useAgentAudio.ts +15 -6
- package/custom/speech_recognition_frontend/MicrophoneButon.vue +4 -7
- package/dist/custom/composables/useAgentAudio.ts +15 -6
- package/dist/custom/speech_recognition_frontend/MicrophoneButon.vue +4 -7
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -58,5 +58,5 @@ custom/speech_recognition_frontend/voiceActivityDetection.ts
|
|
|
58
58
|
custom/speech_recognition_frontend/types/
|
|
59
59
|
custom/speech_recognition_frontend/types/voice-activity-detection.d.ts
|
|
60
60
|
|
|
61
|
-
sent 1,660,
|
|
62
|
-
total size is 1,656,
|
|
61
|
+
sent 1,660,390 bytes received 860 bytes 3,322,500.00 bytes/sec
|
|
62
|
+
total size is 1,656,528 speedup is 1.00
|
|
@@ -49,7 +49,7 @@ function restartStandByAudio() {
|
|
|
49
49
|
|
|
50
50
|
export const useAgentAudio = defineStore('agentAudio', () => {
|
|
51
51
|
const agentStore = useAgentStore();
|
|
52
|
-
const agentAudioMode = ref<'transcribing' | 'streaming' | 'fetchingAudio' | 'playingAgentResponse' |
|
|
52
|
+
const agentAudioMode = ref<'transcribing' | 'streaming' | 'fetchingAudio' | 'playingAgentResponse' | 'readyToRespond' >('readyToRespond');
|
|
53
53
|
const isStreamingResponse = ref(false);
|
|
54
54
|
|
|
55
55
|
let currentAbortController: AbortController | null = null;
|
|
@@ -59,15 +59,21 @@ export const useAgentAudio = defineStore('agentAudio', () => {
|
|
|
59
59
|
let currentStreamingAudio: StreamingAudioState | null = null;
|
|
60
60
|
let bufferedAudioChunks: ArrayBuffer[] = [];
|
|
61
61
|
let bufferedAudioMimeType = 'audio/mpeg';
|
|
62
|
+
let wasAudioResponseReceived = false;
|
|
62
63
|
|
|
63
64
|
function stopGenerationAndAudio() {
|
|
64
|
-
|
|
65
|
+
setAudioModeReadyToRespond();
|
|
65
66
|
stopCurrentAudioPlayback();
|
|
66
67
|
currentAbortController?.abort();
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
function setAudioModeReadyToRespond() {
|
|
71
|
+
agentAudioMode.value = 'readyToRespond';
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
async function sendAudioToServerAndHandleResponse(blob: Blob) {
|
|
70
75
|
currentAbortController = new AbortController();
|
|
76
|
+
wasAudioResponseReceived = false;
|
|
71
77
|
const formData = new FormData();
|
|
72
78
|
formData.append('file', blob, 'user_prompt.wav');
|
|
73
79
|
formData.append('sessionId', agentStore.activeSessionId);
|
|
@@ -101,7 +107,9 @@ export const useAgentAudio = defineStore('agentAudio', () => {
|
|
|
101
107
|
}
|
|
102
108
|
} finally {
|
|
103
109
|
isStreamingResponse.value = false;
|
|
104
|
-
|
|
110
|
+
if (!wasAudioResponseReceived) {
|
|
111
|
+
setAudioModeReadyToRespond();
|
|
112
|
+
}
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
|
|
@@ -177,14 +185,15 @@ export const useAgentAudio = defineStore('agentAudio', () => {
|
|
|
177
185
|
stopStandByAudio();
|
|
178
186
|
agentStore.setCurrentChatStatus('ready');
|
|
179
187
|
agentStore.addAgentMessage(event.data.response.text);
|
|
180
|
-
agentAudioMode.value = 'playingAgentResponse';
|
|
181
188
|
return;
|
|
182
189
|
}
|
|
183
190
|
|
|
184
191
|
if (event.type === 'audio-start') {
|
|
192
|
+
wasAudioResponseReceived = true;
|
|
185
193
|
isStreamingResponse.value = false;
|
|
186
194
|
agentAudioMode.value = 'fetchingAudio';
|
|
187
195
|
initializeAudioStream(event.data.mimeType);
|
|
196
|
+
agentAudioMode.value = 'playingAgentResponse';
|
|
188
197
|
return;
|
|
189
198
|
}
|
|
190
199
|
|
|
@@ -348,12 +357,12 @@ export const useAgentAudio = defineStore('agentAudio', () => {
|
|
|
348
357
|
detachStreamingAudio();
|
|
349
358
|
destroyCurrentAudioElement();
|
|
350
359
|
if (!dontResetMode) {
|
|
351
|
-
|
|
360
|
+
setAudioModeReadyToRespond();
|
|
352
361
|
}
|
|
353
362
|
}
|
|
354
363
|
|
|
355
364
|
function handleAudioEnded() {
|
|
356
|
-
|
|
365
|
+
setAudioModeReadyToRespond();
|
|
357
366
|
stopCurrentAudioPlayback();
|
|
358
367
|
}
|
|
359
368
|
|
|
@@ -63,7 +63,7 @@ onMounted(() => {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
watch(agentAudioMode, (newVal) => {
|
|
66
|
+
watch(agentAudioMode, async (newVal) => {
|
|
67
67
|
if(newVal === 'streaming') {
|
|
68
68
|
stopCurrentAudioPlayback(true);
|
|
69
69
|
microphoneButtonMode.value = 'generating';
|
|
@@ -72,10 +72,11 @@ watch(agentAudioMode, (newVal) => {
|
|
|
72
72
|
} else if (newVal === 'fetchingAudio') {
|
|
73
73
|
//Generation is done, waiting for audio to be ready
|
|
74
74
|
} else if (newVal === 'playingAgentResponse') {
|
|
75
|
-
// Audio is playing
|
|
76
|
-
} else {
|
|
75
|
+
// Audio is playing'
|
|
76
|
+
} else if (newVal === 'readyToRespond') {
|
|
77
77
|
if(isAudioChatMode.value) {
|
|
78
78
|
microphoneButtonMode.value = 'listen';
|
|
79
|
+
await requestMicAndStartVAD(saidSomething, stopRecording, onAnySound);
|
|
79
80
|
} else {
|
|
80
81
|
microphoneButtonMode.value = 'off';
|
|
81
82
|
}
|
|
@@ -142,12 +143,8 @@ async function sendRecordForTranscription() {
|
|
|
142
143
|
showAudioWavesAnimation.value = false;
|
|
143
144
|
const recordBlob = await getRecord();
|
|
144
145
|
if (recordBlob) {
|
|
145
|
-
console.log('Audio recorded, sending to server for transcription. Audio Blob size:', recordBlob.size, recordBlob.type);
|
|
146
146
|
onStopRecording();
|
|
147
147
|
await sendAudioToServerAndHandleResponse(recordBlob);
|
|
148
|
-
if (agentStore.isAudioChatMode) {
|
|
149
|
-
await requestMicAndStartVAD(saidSomething, stopRecording, onAnySound);
|
|
150
|
-
}
|
|
151
148
|
} else {
|
|
152
149
|
console.error('No audio recorded');
|
|
153
150
|
}
|
|
@@ -49,7 +49,7 @@ function restartStandByAudio() {
|
|
|
49
49
|
|
|
50
50
|
export const useAgentAudio = defineStore('agentAudio', () => {
|
|
51
51
|
const agentStore = useAgentStore();
|
|
52
|
-
const agentAudioMode = ref<'transcribing' | 'streaming' | 'fetchingAudio' | 'playingAgentResponse' |
|
|
52
|
+
const agentAudioMode = ref<'transcribing' | 'streaming' | 'fetchingAudio' | 'playingAgentResponse' | 'readyToRespond' >('readyToRespond');
|
|
53
53
|
const isStreamingResponse = ref(false);
|
|
54
54
|
|
|
55
55
|
let currentAbortController: AbortController | null = null;
|
|
@@ -59,15 +59,21 @@ export const useAgentAudio = defineStore('agentAudio', () => {
|
|
|
59
59
|
let currentStreamingAudio: StreamingAudioState | null = null;
|
|
60
60
|
let bufferedAudioChunks: ArrayBuffer[] = [];
|
|
61
61
|
let bufferedAudioMimeType = 'audio/mpeg';
|
|
62
|
+
let wasAudioResponseReceived = false;
|
|
62
63
|
|
|
63
64
|
function stopGenerationAndAudio() {
|
|
64
|
-
|
|
65
|
+
setAudioModeReadyToRespond();
|
|
65
66
|
stopCurrentAudioPlayback();
|
|
66
67
|
currentAbortController?.abort();
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
function setAudioModeReadyToRespond() {
|
|
71
|
+
agentAudioMode.value = 'readyToRespond';
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
async function sendAudioToServerAndHandleResponse(blob: Blob) {
|
|
70
75
|
currentAbortController = new AbortController();
|
|
76
|
+
wasAudioResponseReceived = false;
|
|
71
77
|
const formData = new FormData();
|
|
72
78
|
formData.append('file', blob, 'user_prompt.wav');
|
|
73
79
|
formData.append('sessionId', agentStore.activeSessionId);
|
|
@@ -101,7 +107,9 @@ export const useAgentAudio = defineStore('agentAudio', () => {
|
|
|
101
107
|
}
|
|
102
108
|
} finally {
|
|
103
109
|
isStreamingResponse.value = false;
|
|
104
|
-
|
|
110
|
+
if (!wasAudioResponseReceived) {
|
|
111
|
+
setAudioModeReadyToRespond();
|
|
112
|
+
}
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
|
|
@@ -177,14 +185,15 @@ export const useAgentAudio = defineStore('agentAudio', () => {
|
|
|
177
185
|
stopStandByAudio();
|
|
178
186
|
agentStore.setCurrentChatStatus('ready');
|
|
179
187
|
agentStore.addAgentMessage(event.data.response.text);
|
|
180
|
-
agentAudioMode.value = 'playingAgentResponse';
|
|
181
188
|
return;
|
|
182
189
|
}
|
|
183
190
|
|
|
184
191
|
if (event.type === 'audio-start') {
|
|
192
|
+
wasAudioResponseReceived = true;
|
|
185
193
|
isStreamingResponse.value = false;
|
|
186
194
|
agentAudioMode.value = 'fetchingAudio';
|
|
187
195
|
initializeAudioStream(event.data.mimeType);
|
|
196
|
+
agentAudioMode.value = 'playingAgentResponse';
|
|
188
197
|
return;
|
|
189
198
|
}
|
|
190
199
|
|
|
@@ -348,12 +357,12 @@ export const useAgentAudio = defineStore('agentAudio', () => {
|
|
|
348
357
|
detachStreamingAudio();
|
|
349
358
|
destroyCurrentAudioElement();
|
|
350
359
|
if (!dontResetMode) {
|
|
351
|
-
|
|
360
|
+
setAudioModeReadyToRespond();
|
|
352
361
|
}
|
|
353
362
|
}
|
|
354
363
|
|
|
355
364
|
function handleAudioEnded() {
|
|
356
|
-
|
|
365
|
+
setAudioModeReadyToRespond();
|
|
357
366
|
stopCurrentAudioPlayback();
|
|
358
367
|
}
|
|
359
368
|
|
|
@@ -63,7 +63,7 @@ onMounted(() => {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
watch(agentAudioMode, (newVal) => {
|
|
66
|
+
watch(agentAudioMode, async (newVal) => {
|
|
67
67
|
if(newVal === 'streaming') {
|
|
68
68
|
stopCurrentAudioPlayback(true);
|
|
69
69
|
microphoneButtonMode.value = 'generating';
|
|
@@ -72,10 +72,11 @@ watch(agentAudioMode, (newVal) => {
|
|
|
72
72
|
} else if (newVal === 'fetchingAudio') {
|
|
73
73
|
//Generation is done, waiting for audio to be ready
|
|
74
74
|
} else if (newVal === 'playingAgentResponse') {
|
|
75
|
-
// Audio is playing
|
|
76
|
-
} else {
|
|
75
|
+
// Audio is playing'
|
|
76
|
+
} else if (newVal === 'readyToRespond') {
|
|
77
77
|
if(isAudioChatMode.value) {
|
|
78
78
|
microphoneButtonMode.value = 'listen';
|
|
79
|
+
await requestMicAndStartVAD(saidSomething, stopRecording, onAnySound);
|
|
79
80
|
} else {
|
|
80
81
|
microphoneButtonMode.value = 'off';
|
|
81
82
|
}
|
|
@@ -142,12 +143,8 @@ async function sendRecordForTranscription() {
|
|
|
142
143
|
showAudioWavesAnimation.value = false;
|
|
143
144
|
const recordBlob = await getRecord();
|
|
144
145
|
if (recordBlob) {
|
|
145
|
-
console.log('Audio recorded, sending to server for transcription. Audio Blob size:', recordBlob.size, recordBlob.type);
|
|
146
146
|
onStopRecording();
|
|
147
147
|
await sendAudioToServerAndHandleResponse(recordBlob);
|
|
148
|
-
if (agentStore.isAudioChatMode) {
|
|
149
|
-
await requestMicAndStartVAD(saidSomething, stopRecording, onAnySound);
|
|
150
|
-
}
|
|
151
148
|
} else {
|
|
152
149
|
console.error('No audio recorded');
|
|
153
150
|
}
|