Skip to main content

TalkLabs - Unified TTS Engine and SDK

Project description

🎙️ TalkLabs - ElevenLabs Compatible TTS

TalkLabs Logo Python License

Text-to-Speech de alta qualidade compatível com ElevenLabs, powered by XTTS2

DocumentaçãoAPI ReferenceExemplos


✨ Features

  • 🎯 100% compatível com ElevenLabs API - Drop-in replacement
  • 🚀 Streaming em tempo real - HTTP e WebSocket
  • 🌍 Multi-idioma - Português, Inglês, Espanhol, Francês, Alemão, Italiano
  • 🎭 Voice Cloning - Clone qualquer voz com 3-5 amostras
  • Alta Performance - CUDA acelerado com suporte RTX
  • 🔒 Self-hosted - Seus dados, seu servidor

🚀 Quick Start

Instalação

# Instalar TalkLabs
cd /home/francisco/talklabs
pip install -e .

# Ou via pip (quando publicado)
pip install talklabs

Iniciar API

# Iniciar servidor
python api/main.py

# Ou via uvicorn
uvicorn api.main:app --host 0.0.0.0 --port 5000

Uso do SDK

from talklabs import TalkLabsClient

# Inicializar cliente
client = TalkLabsClient(
    api_key="TALKLABS_SECRET_KEY",
    base_url="http://localhost:5000"
)

# Gerar áudio
audio = client.generate(
    text="Olá, mundo!",
    voice="yasmin_alves",
    speed=1.0
)

# Salvar arquivo
with open("output.wav", "wb") as f:
    f.write(audio)

📖 Exemplos

1. Geração Simples

from talklabs import generate

audio = generate(
    text="Bem-vindo ao TalkLabs!",
    voice="yasmin_alves",
    api_key="TALKLABS_SECRET_KEY"
)

2. Streaming

from talklabs import TalkLabsClient

client = TalkLabsClient(api_key="...")

with open("stream.wav", "wb") as f:
    for chunk in client.generate_stream(
        text="Texto longo para streaming...",
        voice="yasmin_alves"
    ):
        f.write(chunk)

3. Com Timestamps

result = client.generate_with_timestamps(
    text="Olá mundo",
    voice="yasmin_alves"
)

# Áudio em base64
audio_bytes = base64.b64decode(result["audio_base64"])

# Timestamps de cada palavra
for word in result["alignment"]:
    print(f"{word['word']}: {word['start']}s - {word['end']}s")

4. WebSocket Streaming

import asyncio

async def main():
    client = TalkLabsClient(api_key="...")
    
    async def text_stream():
        yield "Olá, "
        await asyncio.sleep(0.5)
        yield "mundo!"
    
    async for audio_chunk in client.stream_input(
        text_iterator=text_stream(),
        voice="yasmin_alves"
    ):
        # Processar chunk de áudio
        pass

asyncio.run(main())

🎭 Clonando Vozes

# 1. Criar diretório para nova voz
mkdir -p samples/minha_voz

# 2. Adicionar 3-5 amostras WAV (16kHz, mono, 10-30s cada)
cp amostra1.wav samples/minha_voz/
cp amostra2.wav samples/minha_voz/
cp amostra3.wav samples/minha_voz/

# 3. Reiniciar servidor
# A voz estará disponível automaticamente!

🔌 API Endpoints

Endpoint Método Descrição
/v1/text-to-speech/{voice_id} POST TTS padrão
/v1/text-to-speech/{voice_id}/stream POST Streaming HTTP
/v1/text-to-speech/{voice_id}/with-timestamps POST TTS com timestamps
/v1/text-to-speech/{voice_id}/stream-input WS WebSocket streaming
/v1/voices GET Listar vozes
/v1/models GET Listar modelos
/health GET Health check

🎛️ Parâmetros

client.generate(
    text="Seu texto aqui",
    voice="yasmin_alves",
    speed=1.0,           # 0.25 a 4.0
    language="pt",       # pt, en, es, fr, de, it
    voice_settings={
        "stability": 0.75,        # 0.0 a 1.0
        "similarity_boost": 0.75,
        "style": 0.0,
        "use_speaker_boost": True
    }
)

🌐 Usando via cURL

curl -X POST "http://localhost:5000/v1/text-to-speech/yasmin_alves" \
     -H "xi-api-key: TALKLABS_SECRET_KEY" \
     -H "Content-Type: application/json" \
     -d '{"text":"Olá mundo!","speed":1.2}' \
     --output audio.wav

🔧 Configuração

# .env ou variáveis de ambiente
TALKLABS_API_KEY=your_secret_key_here
TALKLABS_HOST=0.0.0.0
TALKLABS_PORT=5000
CUDA_VISIBLE_DEVICES=0  # GPU a usar

📊 Benchmarks

Métrica Valor
Latência primeira chunk ~200ms
Throughput ~50 caracteres/segundo
Qualidade MOS 4.2/5.0
Idiomas suportados 6+
GPU mínima GTX 1060 6GB
GPU recomendada RTX 3090+

🐛 Troubleshooting

CUDA Out of Memory

# Reduzir batch size ou usar CPU
engine = TalkLabsEngine(device="cpu")

Voz não encontrada

# Verificar vozes disponíveis
curl http://localhost:5000/v1/voices

Latência alta

# Usar modelo flash
client.generate(text="...", model="eleven_flash_v2_5")

🤝 Contribuindo

Contribuições são bem-vindas! Por favor:

  1. Fork o projeto
  2. Crie uma branch (git checkout -b feature/nova-feature)
  3. Commit suas mudanças (git commit -am 'Add nova feature')
  4. Push para a branch (git push origin feature/nova-feature)
  5. Abra um Pull Request

📄 Licença

MIT License - veja LICENSE para detalhes.

🙏 Créditos


WebsiteDocumentaçãoDiscord

Made with ❤️ by TalkLabs Team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

talklabs-1.0.2.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

talklabs-1.0.2-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file talklabs-1.0.2.tar.gz.

File metadata

  • Download URL: talklabs-1.0.2.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for talklabs-1.0.2.tar.gz
Algorithm Hash digest
SHA256 19349c0524d560cb08bc4908ab35fc8026e813304431db71481e3c2d540d2c51
MD5 14308f16ab7a7e80b2cae31d07e0af37
BLAKE2b-256 e741ba1c0ed65c97fe77522ce4456314d677ed71200acf1d6a1f2fdeadbf6a18

See more details on using hashes here.

File details

Details for the file talklabs-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: talklabs-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for talklabs-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4b9f7cfa98c4bfb41bf9ac5734ce12d1e68d6c09798fd3451e82ca182edfe163
MD5 4126ee53ac0f3e9eeb8abc78902b0e19
BLAKE2b-256 9ab0ed8f261dae7a6e88ec0dde528f01c9770e0815e6c4d6210d48bda334d062

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page