Développeurs
API, WebSocket TTS & scripts prêts à l'emploi
Clés API
Connectez-vous pour gérer vos clés API
Infos rapides
- Auth: Header
X-API-Key - WebSocket: Temps réel, pas de queue
- Facturation: Débit auto du crédit
- Storage: URLs signées Supabase
Endpoints API
| Méthode | Endpoint | Description |
|---|---|---|
| POST | /api/v1/tts/ | TTS synchrone (texte court) |
| WS | /api/v1/tts/stream | TTS WebSocket temps réel |
| GET | /api/v1/voices/ | Liste vos voix privées |
| GET | /api/v1/tts/history | Historique TTS |
| GET | /api/v1/community/models | 100k+ voix communauté |
ws://localhost:8000/api/v1/tts/streamScripts prêts à l'emploi
"""
Client Python complet pour l'API FR02
Installez: pip install httpx httpx-ws
"""
import os
import json
from pathlib import Path
import httpx
from httpx_ws import connect_ws
API_KEY = os.getenv("FR02_API_KEY", "VOTRE_CLE_API")
BASE_URL = "http://localhost:8000/api/v1"
def get_client():
return httpx.Client(base_url=BASE_URL, headers={"X-API-Key": API_KEY}, timeout=30.0)
# ═══════════════════════════════════════════════════════════════
# 1. LISTER VOS VOIX PRIVÉES
# ═══════════════════════════════════════════════════════════════
def list_my_voices():
"""Récupère vos voix clonées avec leurs IDs."""
with get_client() as client:
resp = client.get("/voices/")
resp.raise_for_status()
voices = resp.json()["voices"]
for v in voices:
print(f"ID: {v['fish_audio_model_id']} | Titre: {v['title']}")
return voices
# ═══════════════════════════════════════════════════════════════
# 2. CHERCHER DANS LES VOIX COMMUNAUTAIRES
# ═══════════════════════════════════════════════════════════════
def search_community_voices(query: str = "", page: int = 1):
"""Recherche dans les 100k+ voix communautaires."""
with get_client() as client:
resp = client.get(f"/community/models?search={query}&page={page}&page_size=10")
resp.raise_for_status()
models = resp.json()["models"]
for m in models:
print(f"ID: {m['fish_audio_id']} | {m['title']} by {m['author_nickname']}")
return models
# ═══════════════════════════════════════════════════════════════
# 3. TTS WEBSOCKET (temps réel)
# ═══════════════════════════════════════════════════════════════
def tts_websocket(text: str, voice_id: str = None):
"""Génère de l'audio via WebSocket TTS en temps réel."""
with httpx.Client(base_url="http://localhost:8000", timeout=30.0) as client:
with connect_ws("/api/v1/tts/stream", client=client, headers={"X-API-Key": API_KEY}) as ws:
ws.send_text(json.dumps({"text": text, "voice_id": voice_id, "format": "mp3"}))
audio_chunks = []
try:
while True:
audio_chunks.append(ws.receive_bytes())
except Exception:
pass
return b"".join(audio_chunks)
if __name__ == "__main__":
# Lister vos voix
print("=== Vos voix privées ===")
voices = list_my_voices()
# Chercher une voix communautaire
print("\n=== Voix communautaires (trump) ===")
search_community_voices("trump")
# Générer TTS avec votre première voix
if voices:
audio = tts_websocket("Bonjour!", voice_id=voices[0]["fish_audio_model_id"])
Path("output.mp3").write_bytes(audio)
print(f"\nAudio sauvegardé: output.mp3")
Dépendances: pip install httpx httpx-ws
Paramètres TTS
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
| text * | string | — | Texte à synthétiser (requis) |
| voice_id | string | default | ID Fish Audio de la voix |
| format | string | mp3 | mp3, wav, pcm, opus |
| speed | float | 1.0 | Vitesse (0.5 – 2.0) |
| volume | float | 0.0 | Volume dB (-20 à +20) |
| temperature | float | 0.7 | Variabilité (0.1 – 1.5) |
| latency | string | balanced | normal, balanced, low |