NewElevenLabs (tts/elevenlabs.go)

voiceblender · internal/tts/elevenlabs.go · go · MIT
voice, Voice / Speech

Provides a Go client for ElevenLabs TTS streaming API with configurable options.

// Source: https://github.com/VoiceBlender/voiceblender | License: MIT | Copyright 2026 Messageroute Ltd
// Provided via justclaw.it.com; keep this notice with the code.
package tts

import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"log/slog"
	"net/http"
	"net/url"

	"github.com/VoiceBlender/voiceblender/internal/providercfg"
)

const (
	elevenLabsDefaultModel = "eleven_multilingual_v2"
)

// ElevenLabs implements Provider using the ElevenLabs streaming TTS API.
type ElevenLabs struct {
	apiKey string
	cfg    providercfg.ElevenLabs
	client *http.Client
	log    *slog.Logger
}

// NewElevenLabs creates an ElevenLabs TTS provider.
func NewElevenLabs(apiKey string, cfg providercfg.ElevenLabs, log *slog.Logger) *ElevenLabs {
	return &ElevenLabs{
		apiKey: apiKey,
		cfg:    cfg,
		cli

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key