mnemo_cards/mnemo_cards_admin/src/api/voiceService.ts

33 lines
878 B
TypeScript
Raw Normal View History

2026-01-24 16:01:36 +00:00
import { adminApiClient } from './client'
export interface GenerateTTSResponse {
objectId: string
url: string // Presigned URL for preview
}
export const voiceServiceApi = {
/**
* Generate TTS audio from text via backend API
* Backend calls voice-service, which handles caching, and saves to MinIO
* @param text Text to convert to speech
* @param voice Voice identifier (optional, defaults to 'alloy')
2026-01-24 16:59:04 +00:00
* @param language Language code (optional)
2026-01-24 16:01:36 +00:00
* @returns Object ID and presigned URL
*/
async generateTTS(
text: string,
2026-01-24 16:59:04 +00:00
voice?: string,
language?: string
2026-01-24 16:01:36 +00:00
): Promise<GenerateTTSResponse> {
const response = await adminApiClient.post<GenerateTTSResponse>(
'/api/v2/media/generate-tts',
{
text,
voice: voice || 'alloy',
2026-01-24 16:59:04 +00:00
...(language && { language }),
2026-01-24 16:01:36 +00:00
}
)
return response.data
},
}