| 12345678910111213141516171819202122232425262728 |
- """À exécuter depuis le pod Satoko ; aucun appel à Discord."""
- import io
- import json
- import time
- import wave
- import httpx
- with httpx.Client(timeout=90) as http:
- health = http.get('http://kokoro-tts:8000/healthz')
- health.raise_for_status()
- print(health.json())
- for text in (
- 'Bonjour, je suis prête à discuter avec vous.',
- 'Tu peux maintenant me parler dans le salon vocal, et je te répondrai directement à voix haute.',
- 'Les trois serveurs fonctionnent correctement. Nous pouvons continuer notre partie tranquillement.',
- ):
- started = time.monotonic()
- response = http.post('http://kokoro-tts:8000/v1/audio/speech', json={'input': text, 'voice': 'ff_siwis'})
- response.raise_for_status()
- with wave.open(io.BytesIO(response.content)) as wav:
- assert wav.getframerate() == 24000 and wav.getnchannels() == 1 and wav.getsampwidth() == 2
- duration = wav.getnframes() / wav.getframerate()
- print(json.dumps({'characters': len(text), 'request_seconds': round(time.monotonic()-started, 3),
- 'generation_seconds': response.headers.get('X-Generation-Seconds'),
- 'audio_seconds': round(duration, 3)}, ensure_ascii=False))
- invalid = http.post('http://kokoro-tts:8000/v1/audio/speech', json={'input': 'bonjour', 'voice': '../unknown'})
- assert invalid.status_code == 422
- print('WAV et validation de voix : OK')
|