UNPKG

primvoices

Version:

TypeScript client for the Prim Voices API

85 lines (84 loc) 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VoicesAPI = void 0; class VoicesAPI { constructor(client) { this.client = client; } /** * List all voices for the authenticated user * GET /v1/voices */ async list(params) { const response = await this.client.get('/v1/voices', { params }); return { data: response.data.data, status: response.status, success: true }; } /** * Get a specific voice by ID * GET /v1/voices/:id */ async retrieve(voiceId) { const response = await this.client.get(`/v1/voices/${voiceId}`); return { data: response.data.data, status: response.status, success: true }; } /** * Create a new voice * POST /v1/voices * * @param params.name - Name of the voice * @param params.sampleUrl - URL of the sample audio file */ async create(params) { const response = await this.client.post('/v1/voices', params); return { data: response.data.data, status: response.status, success: true }; } /** * Delete a voice * DELETE /v1/voices/:id */ async delete(voiceId) { const response = await this.client.delete(`/v1/voices/${voiceId}`); return { data: response.data, status: response.status, success: true }; } /** * List all public voices * GET /v1/publicVoices */ async listPublic(params) { const response = await this.client.get('/v1/publicVoices', { params }); return { data: response.data.data, status: response.status, success: true }; } /** * Get a specific public voice by ID * GET /v1/publicVoices/:id */ async retrievePublic(voiceId) { const response = await this.client.get(`/v1/publicVoices/${voiceId}`); return { data: response.data.data, status: response.status, success: true }; } } exports.VoicesAPI = VoicesAPI;