Skip to content

Commit c907abe

Browse files
Revert "Wait until the output_audio_buffer is empty"
This reverts commit 32cfd8d.
1 parent 69c1201 commit c907abe

File tree

2 files changed

+0
-44
lines changed

2 files changed

+0
-44
lines changed

src/app/hooks/useHandleServerEvent.ts

-43
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@ export function useHandleServerEvent({
3131

3232
const { logServerEvent } = useEvent();
3333

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-
5134
const handleFunctionCall = async (functionCallParams: {
5235
name: string;
5336
call_id?: string;
@@ -76,15 +59,11 @@ export function useHandleServerEvent({
7659
output: JSON.stringify(fnResult),
7760
},
7861
});
79-
80-
await waitUntilAudioBuffersEmpty();
8162
sendClientEvent({ type: "response.create" });
8263
} else if (functionCallParams.name === "transferAgents") {
8364
const destinationAgent = args.destination_agent;
8465
const newAgentConfig =
8566
selectedAgentConfigSet?.find((a) => a.name === destinationAgent) || null;
86-
87-
await waitUntilAudioBuffersEmpty();
8867
if (newAgentConfig) {
8968
setSelectedAgentName(destinationAgent);
9069
}
@@ -119,8 +98,6 @@ export function useHandleServerEvent({
11998
output: JSON.stringify(simulatedResult),
12099
},
121100
});
122-
123-
await waitUntilAudioBuffersEmpty();
124101
sendClientEvent({ type: "response.create" });
125102
}
126103
};
@@ -210,26 +187,6 @@ export function useHandleServerEvent({
210187
break;
211188
}
212189

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-
233190
default:
234191
break;
235192
}

src/app/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export interface Log {
6565
export interface ServerEvent {
6666
type: string;
6767
event_id?: string;
68-
response_id?: string;
6968
item_id?: string;
7069
transcript?: string;
7170
delta?: string;

0 commit comments

Comments
 (0)