MediaSFU Angular
    Preparing search index...

    Function fetchVoicesViaSocket

    • Fetch voices via socket connection (keeps API keys server-side)

      This is the ONLY method for frontend voice fetching as it:

      • Keeps TTS API keys on the server (security)
      • Uses cached results from server
      • Falls back to static lists if fetch fails

      The backend will use the room's/user's configured TTS credentials to fetch voices.

      Parameters

      • socket: {
            emit: (
                event: string,
                data: unknown,
                callback?: (response: SocketVoiceResponse) => void,
            ) => void;
        }

        Socket.io socket instance

      • provider: string = 'deepgram'

        TTS provider name (e.g., 'deepgram', 'elevenlabs', 'openai')

      • language: string = 'en'

        Language code (optional, default 'en')

      Returns Promise<SocketVoiceResponse>

      Promise with voices

      // In your React component
      const voices = await fetchVoicesViaSocket(socket, 'elevenlabs', 'en');
      console.log(voices.voices.male, voices.voices.female);