File tree Expand file tree Collapse file tree 8 files changed +100
-1
lines changed
Expand file tree Collapse file tree 8 files changed +100
-1
lines changed Original file line number Diff line number Diff line change 33__pycache__ /
44poetry.toml
55.ruff_cache /
6+ .DS_Store
Original file line number Diff line number Diff line change 1+ from elevenlabs import play
2+ from elevenlabs .client import ElevenLabs
3+
4+ from .utils import IN_GITHUB , DEFAULT_VOICE_FILE
5+
6+
7+ def test_audio_isolation () -> None :
8+ """Test basic audio isolation."""
9+ client = ElevenLabs ()
10+ audio_file = open (DEFAULT_VOICE_FILE , "rb" )
11+ try :
12+ audio_stream = client .audio_isolation .audio_isolation (audio = audio_file )
13+ audio = b"" .join (chunk for chunk in audio_stream )
14+ assert isinstance (audio , bytes ), "Combined audio should be bytes"
15+ if not IN_GITHUB :
16+ play (audio )
17+ finally :
18+ audio_file .close ()
19+
20+
21+ def test_audio_isolation_as_stream ():
22+ """Test audio isolation with streaming."""
23+ client = ElevenLabs ()
24+ audio_file = open (DEFAULT_VOICE_FILE , "rb" )
25+ try :
26+ audio_stream = client .audio_isolation .audio_isolation_stream (audio = audio_file )
27+ audio = b"" .join (chunk for chunk in audio_stream )
28+ assert isinstance (audio , bytes ), "Combined audio should be bytes"
29+ if not IN_GITHUB :
30+ play (audio )
31+ finally :
32+ audio_file .close ()
Original file line number Diff line number Diff line change 22from elevenlabs .client import ElevenLabs
33
44
5- def test_models ():
5+ def test_models_get_all ():
66 client = ElevenLabs ()
77 models = client .models .get_all ()
88 assert len (models ) > 0
Original file line number Diff line number Diff line change 1+ from elevenlabs import play
2+ from elevenlabs .client import ElevenLabs
3+
4+ from .utils import IN_GITHUB , DEFAULT_VOICE , DEFAULT_VOICE_FILE
5+
6+
7+ def test_sts () -> None :
8+ """Test basic speech-to-speech generation."""
9+ client = ElevenLabs ()
10+ audio_file = open (DEFAULT_VOICE_FILE , "rb" )
11+ try :
12+ audio_stream = client .speech_to_speech .convert (voice_id = DEFAULT_VOICE , audio = audio_file )
13+ audio = b"" .join (chunk for chunk in audio_stream )
14+ assert isinstance (audio , bytes ), "Combined audio should be bytes"
15+ if not IN_GITHUB :
16+ play (audio )
17+ finally :
18+ audio_file .close ()
19+
20+
21+ def test_sts_as_stream ():
22+ client = ElevenLabs ()
23+ audio_file = open (DEFAULT_VOICE_FILE , "rb" )
24+ try :
25+ audio_stream = client .speech_to_speech .convert_as_stream (voice_id = DEFAULT_VOICE , audio = audio_file )
26+ audio = b"" .join (chunk for chunk in audio_stream )
27+ assert isinstance (audio , bytes ), "Combined audio should be bytes"
28+ if not IN_GITHUB :
29+ play (audio )
30+ finally :
31+ audio_file .close ()
Original file line number Diff line number Diff line change 1+ from elevenlabs import play
2+ from elevenlabs .client import ElevenLabs
3+
4+ from .utils import IN_GITHUB
5+
6+
7+ def test_text_to_sound_effects_convert () -> None :
8+ """Test basic sound-effect generation."""
9+ client = ElevenLabs ()
10+ audio_generator = client .text_to_sound_effects .convert (
11+ text = "Hypnotic throbbing sound effect. Increases in imtensity." ,
12+ duration_seconds = 2 ,
13+ )
14+ audio = b"" .join (audio_generator )
15+ assert isinstance (audio , bytes ), "TTS should return bytes"
16+ if not IN_GITHUB :
17+ play (audio )
Original file line number Diff line number Diff line change 1+ from elevenlabs .client import ElevenLabs
2+
3+
4+ def test_voice_preview_generation ():
5+ """Test generating voice previews from description."""
6+ client = ElevenLabs ()
7+
8+ # Test parameters
9+ description = "A warm and friendly female voice with a slight British accent, speaking clearly and professionally"
10+ sample_text = "This is a test message that needs to be at least one hundred characters long to meet the API requirements. Here it is."
11+
12+ previews = client .text_to_voice .create_previews (voice_description = description , text = sample_text )
13+
14+ assert hasattr (previews , "previews" ), "Response should have 'previews' attribute"
15+ assert len (previews .previews ) > 0 , "Should receive at least one preview"
16+ assert hasattr (previews .previews [0 ], "generated_voice_id" ), "Preview should contain generated_voice_id"
17+ assert hasattr (previews .previews [0 ], "audio_base_64" ), "Preview should contain audio_base_64"
Original file line number Diff line number Diff line change 99DEFAULT_VOICE = "21m00Tcm4TlvDq8ikWAM"
1010DEFAULT_TEXT = "Hello"
1111DEFAULT_MODEL = "eleven_multilingual_v2"
12+ DEFAULT_VOICE_FILE = "tests/fixtures/voice_sample.mp3"
1213
1314
1415def as_local_files (urls : Sequence [str ]) -> Generator [str , None , None ]:
You can’t perform that action at this time.
0 commit comments