@@ -31,23 +31,6 @@ export function useHandleServerEvent({
31
31
32
32
const { logServerEvent } = useEvent ( ) ;
33
33
34
- // A ref to hold the list of active output audio buffers (using their IDs)
35
- const outputAudioBuffersRef = useRef < string [ ] > ( [ ] ) ;
36
-
37
- // Wait until all output audio buffers are empty
38
- async function waitUntilAudioBuffersEmpty ( ) {
39
- if ( outputAudioBuffersRef . current . length > 0 ) {
40
- await new Promise < void > ( ( resolve ) => {
41
- const interval = setInterval ( ( ) => {
42
- if ( outputAudioBuffersRef . current . length === 0 ) {
43
- clearInterval ( interval ) ;
44
- resolve ( ) ;
45
- }
46
- } , 100 ) ;
47
- } ) ;
48
- }
49
- }
50
-
51
34
const handleFunctionCall = async ( functionCallParams : {
52
35
name : string ;
53
36
call_id ?: string ;
@@ -76,15 +59,11 @@ export function useHandleServerEvent({
76
59
output : JSON . stringify ( fnResult ) ,
77
60
} ,
78
61
} ) ;
79
-
80
- await waitUntilAudioBuffersEmpty ( ) ;
81
62
sendClientEvent ( { type : "response.create" } ) ;
82
63
} else if ( functionCallParams . name === "transferAgents" ) {
83
64
const destinationAgent = args . destination_agent ;
84
65
const newAgentConfig =
85
66
selectedAgentConfigSet ?. find ( ( a ) => a . name === destinationAgent ) || null ;
86
-
87
- await waitUntilAudioBuffersEmpty ( ) ;
88
67
if ( newAgentConfig ) {
89
68
setSelectedAgentName ( destinationAgent ) ;
90
69
}
@@ -119,8 +98,6 @@ export function useHandleServerEvent({
119
98
output : JSON . stringify ( simulatedResult ) ,
120
99
} ,
121
100
} ) ;
122
-
123
- await waitUntilAudioBuffersEmpty ( ) ;
124
101
sendClientEvent ( { type : "response.create" } ) ;
125
102
}
126
103
} ;
@@ -210,26 +187,6 @@ export function useHandleServerEvent({
210
187
break ;
211
188
}
212
189
213
- // Handle creation of an output audio buffer.
214
- case "output_audio_buffer.started" : {
215
- // Assuming serverEvent carries a unique buffer ID in serverEvent.response_id.
216
- if ( serverEvent . response_id ) {
217
- outputAudioBuffersRef . current . push ( serverEvent . response_id ) ;
218
- }
219
- break ;
220
- }
221
-
222
- // Handle deletion of an output audio buffer.
223
- case "output_audio_buffer.stopped" :
224
- case "output_audio_buffer.cleared" : {
225
- if ( serverEvent . response_id ) {
226
- outputAudioBuffersRef . current = outputAudioBuffersRef . current . filter (
227
- ( id ) => id !== serverEvent . response_id
228
- ) ;
229
- }
230
- break ;
231
- }
232
-
233
190
default :
234
191
break ;
235
192
}
0 commit comments