mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-12 14:22:21 +00:00
fix: scope voice response parsing to its backend lifetime
This commit is contained in:
1 parent
1a1cbadf5b
commit
c488a18df1
3 files changed
+6
-3
No files matched your search
@@ -7,9 +7,12 @@ export function createRealtimeBackend({
|
|||||||
tokenTransport = (...args) => fetch(...args),
|
tokenTransport = (...args) => fetch(...args),
|
||||||
connectionTransport = (...args) => fetch(...args),
|
connectionTransport = (...args) => fetch(...args),
|
||||||
timeoutMs = 30_000,
|
timeoutMs = 30_000,
|
||||||
|
signal: lifetime,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const scoped = (signal) =>
|
const scoped = (signal) =>
|
||||||
AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)].filter(Boolean));
|
AbortSignal.any(
|
||||||
|
[lifetime, signal, AbortSignal.timeout(timeoutMs)].filter(Boolean),
|
||||||
|
);
|
||||||
return Object.freeze({
|
return Object.freeze({
|
||||||
protocol: 'openai-realtime',
|
protocol: 'openai-realtime',
|
||||||
async requestToken({ tier = DEFAULT_VOICE_TIER, signal } = {}) {
|
async requestToken({ tier = DEFAULT_VOICE_TIER, signal } = {}) {
|
||||||
|
|||||||
@@ -89,12 +89,13 @@ test('cancellation rejects late token and SDP bodies without promoting a stopped
|
|||||||
release = resolve;
|
release = resolve;
|
||||||
});
|
});
|
||||||
const backend = createRealtimeBackend({
|
const backend = createRealtimeBackend({
|
||||||
|
signal: lifetime.signal,
|
||||||
tokenTransport: async () => ({ ok: true, json: () => pending }),
|
tokenTransport: async () => ({ ok: true, json: () => pending }),
|
||||||
connectionTransport: async () => ({ ok: true, text: () => pending }),
|
connectionTransport: async () => ({ ok: true, text: () => pending }),
|
||||||
});
|
});
|
||||||
const result =
|
const result =
|
||||||
phase === 'token'
|
phase === 'token'
|
||||||
? backend.requestToken({ signal: lifetime.signal })
|
? backend.requestToken()
|
||||||
: backend.negotiate({
|
: backend.negotiate({
|
||||||
credential: { token: 'test' },
|
credential: { token: 'test' },
|
||||||
offerSdp: 'offer',
|
offerSdp: 'offer',
|
||||||
|
|||||||
@@ -2598,4 +2598,3 @@ function resetVoiceVisualizerBars(bars) {
|
|||||||
bar.style.removeProperty('--audio-opacity');
|
bar.style.removeProperty('--audio-opacity');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user