Add audio preview functionality for assistant opener audio in AssistantsPage. Implement controls for previewing and stopping audio playback, and integrate new API endpoint for fetching PCM buffer. Enhance user interface with updated button states for audio actions.

This commit is contained in:
Xin Wang
2026-02-26 16:15:31 +08:00
parent fb95e2abe2
commit 0de6fe529e
2 changed files with 118 additions and 9 deletions

View File

@@ -331,6 +331,15 @@ export const generateAssistantOpenerAudio = async (
});
};
export const fetchAssistantOpenerAudioPcmBuffer = async (assistantId: string): Promise<ArrayBuffer> => {
const url = `${getApiBaseUrl()}/assistants/${assistantId}/opener-audio/pcm`;
const response = await fetch(url, { method: 'GET' });
if (!response.ok) {
throw new Error(`Failed to fetch opener audio: ${response.status}`);
}
return response.arrayBuffer();
};
export const fetchVoices = async (): Promise<Voice[]> => {
const response = await apiRequest<{ list?: AnyRecord[] } | AnyRecord[]>(withLimit('/voices'));
const list = Array.isArray(response) ? response : (response.list || []);