File size: 1,046 Bytes
9410704 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | from elevenlabs.play import play
from elevenlabs.client import ElevenLabs
from .utils import IN_GITHUB, DEFAULT_VOICE, DEFAULT_VOICE_FILE
def test_sts() -> None:
"""Test basic speech-to-speech generation."""
client = ElevenLabs()
audio_file = open(DEFAULT_VOICE_FILE, "rb")
try:
audio_stream = client.speech_to_speech.convert(voice_id=DEFAULT_VOICE, audio=audio_file)
audio = b"".join(chunk for chunk in audio_stream)
assert isinstance(audio, bytes), "Combined audio should be bytes"
if not IN_GITHUB:
play(audio)
finally:
audio_file.close()
def test_sts_as_stream():
client = ElevenLabs()
audio_file = open(DEFAULT_VOICE_FILE, "rb")
try:
audio_stream = client.speech_to_speech.stream(voice_id=DEFAULT_VOICE, audio=audio_file)
audio = b"".join(chunk for chunk in audio_stream)
assert isinstance(audio, bytes), "Combined audio should be bytes"
if not IN_GITHUB:
play(audio)
finally:
audio_file.close()
|