TalkLabs - Unified TTS Engine and SDK
Project description
🎙️ TalkLabs - ElevenLabs Compatible TTS
Text-to-Speech de alta qualidade compatível com ElevenLabs, powered by XTTS2
✨ 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:
- Fork o projeto
- Crie uma branch (
git checkout -b feature/nova-feature) - Commit suas mudanças (
git commit -am 'Add nova feature') - Push para a branch (
git push origin feature/nova-feature) - Abra um Pull Request
📄 Licença
MIT License - veja LICENSE para detalhes.
🙏 Créditos
- XTTS2 by Coqui.ai
- Inspirado em ElevenLabs
Website • Documentação • Discord
Made with ❤️ by TalkLabs Team
Project details
Release history Release notifications | RSS feed
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.3.tar.gz
(33.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
talklabs-1.0.3-py3-none-any.whl
(41.4 kB
view details)
File details
Details for the file talklabs-1.0.3.tar.gz.
File metadata
- Download URL: talklabs-1.0.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7193267df4efff1beabf6bef15b1183de8ce84ff484f195f66c787194accb1c4
|
|
| MD5 |
0a148ceb8d9197d7a0fc120c3de0751e
|
|
| BLAKE2b-256 |
8ae783b7c561a9c6ef2dd28d56d295df4119ff5490c392cc05604cdb77025572
|
File details
Details for the file talklabs-1.0.3-py3-none-any.whl.
File metadata
- Download URL: talklabs-1.0.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c30d20ea9a6f01cc66669b311cba1c4ef8715b4026facbd1345ea84b58c0466b
|
|
| MD5 |
23d252ff3b0a0e0fb2c07ee127747c9d
|
|
| BLAKE2b-256 |
b93321002575634563ac69ac342b41b2db64a6ce9df67ef50acc6eaa7c328e64
|