11import asyncio
22
3- from elevenlabs import VoiceSettings , play
3+ from elevenlabs import VoiceSettings , play , Voice
44from elevenlabs .client import AsyncElevenLabs , ElevenLabs
55
66from .utils import IN_GITHUB , DEFAULT_TEXT , DEFAULT_VOICE , DEFAULT_MODEL
@@ -17,6 +17,33 @@ def test_tts_convert() -> None:
1717 play (audio )
1818
1919
20+ def test_tts_generate () -> None :
21+ """Test basic text-to-speech generation w/ custom generate."""
22+ client = ElevenLabs ()
23+ audio_generator = client .generate (text = DEFAULT_TEXT , voice = "Brian" , model = DEFAULT_MODEL )
24+ audio = b"" .join (audio_generator )
25+ assert isinstance (audio , bytes ), "TTS should return bytes"
26+ if not IN_GITHUB :
27+ play (audio )
28+
29+
30+ def test_tts_generate_with_voice_settings () -> None :
31+ """Test basic text-to-speech generation."""
32+ client = ElevenLabs ()
33+ audio_generator = client .generate (
34+ text = DEFAULT_TEXT ,
35+ model = DEFAULT_MODEL ,
36+ voice = Voice (
37+ voice_id = "nPczCjzI2devNBz1zQrb" ,
38+ settings = VoiceSettings (stability = 0.71 , similarity_boost = 0.5 , style = 0.0 , use_speaker_boost = True ),
39+ ),
40+ )
41+ audio = b"" .join (audio_generator )
42+ assert isinstance (audio , bytes ), "TTS should return bytes"
43+ if not IN_GITHUB :
44+ play (audio )
45+
46+
2047def test_tts_convert_with_voice_settings () -> None :
2148 """Test TTS with custom voice settings."""
2249 client = ElevenLabs ()
0 commit comments