Skip to content

Implement ElevenLabs API client infrastructure #1991

@martinbedouret

Description

@martinbedouret

Create the foundational API client for ElevenLabs integration, following the existing Azure Speech Services pattern in the codebase.

Acceptance Criteria

  • Add ElevenLabs API constants to src/constants.js (API base URL, timeout settings)
  • Create ElevenLabs API calls in src/api/api.js with methods:
    • getElevenLabsVoices() - fetch available cloned voices
    • synthesizeSpeechElevenLabs(text, voiceId, settings) - TTS synthesis
  • Add API key validation and connection testing
  • Implement error handling for API failures, rate limits, and network issues
  • Add internet connectivity checks before API calls
  • Support for custom API endpoints and regional configurations

Technical Implementation Notes

// Add to src/constants.js
export const ELEVENLABS_API_BASE_URL = 'https://api.elevenlabs.io/v1';
export const ELEVENLABS_DEFAULT_TIMEOUT = 10000;

// Add to src/api/api.js
async getElevenLabsVoices() {
  const apiKey = this.getElevenLabsApiKey();
  if (!apiKey) return [];

  const headers = { 'xi-api-key': apiKey };
  const url = `${ELEVENLABS_API_BASE_URL}/voices`;

  try {
    const { status, data } = await this.axiosInstance.get(url, { headers });
    if (status === 200) return data.voices || [];
    return [];
  } catch (err) {
    console.error('ElevenLabs API error:', err.message);
    return [];
  }
}

Files to Modify

  • src/constants.js
  • src/api/api.js
  • src/api/api.test.js (add tests)

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions