29 lines
994 B
TypeScript
29 lines
994 B
TypeScript
|
|
import { apiClient } from './client';
|
||
|
|
import type { VoiceAvailability, VoiceExtractionResult } from '@/types/voice';
|
||
|
|
|
||
|
|
export interface ExtractVoicePayload {
|
||
|
|
/** Base64 audio, no data: prefix. */
|
||
|
|
audio: string;
|
||
|
|
format: string;
|
||
|
|
/** IANA zone — the server derives "today" from it for relative deadlines. */
|
||
|
|
timeZone: string;
|
||
|
|
durationMs: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const voiceApi = {
|
||
|
|
availability: async (): Promise<{ success: boolean; data: VoiceAvailability }> => {
|
||
|
|
const response = await apiClient.get('/voice/availability');
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
extract: async (
|
||
|
|
payload: ExtractVoicePayload,
|
||
|
|
signal?: AbortSignal,
|
||
|
|
): Promise<{ success: boolean; data: VoiceExtractionResult }> => {
|
||
|
|
// The signal is forwarded so cancelling closes the connection, which aborts the
|
||
|
|
// metered vendor call server-side rather than letting it settle unseen.
|
||
|
|
const response = await apiClient.post('/voice/extract', payload, { signal });
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
};
|