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:
@@ -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 || []);
|
||||
|
||||
Reference in New Issue
Block a user