Skip to content

Commit 6d4f625

Browse files
committed
chore: add generate test, bump to 1.50.0 & change default model
1 parent f88124c commit 6d4f625

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/elevenlabs/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def generate(
122122
text: Union[str, Iterator[str]],
123123
voice: Union[VoiceId, VoiceName, Voice] = DEFAULT_VOICE,
124124
voice_settings: typing.Optional[VoiceSettings] = DEFAULT_VOICE.settings,
125-
model: Union[ModelId, Model] = "eleven_monolingual_v1",
125+
model: Union[ModelId, Model] = "eleven_multilingual_v2",
126126
optimize_streaming_latency: typing.Optional[int] = 0,
127127
stream: bool = False,
128128
output_format: Optional[OutputFormat] = "mp3_44100_128",
@@ -302,7 +302,7 @@ async def generate(
302302
text: str,
303303
voice: Union[VoiceId, VoiceName, Voice] = DEFAULT_VOICE,
304304
voice_settings: typing.Optional[VoiceSettings] = DEFAULT_VOICE.settings,
305-
model: Union[ModelId, Model] = "eleven_monolingual_v1",
305+
model: Union[ModelId, Model] = "eleven_multilingual_v2",
306306
optimize_streaming_latency: typing.Optional[int] = 0,
307307
stream: bool = False,
308308
output_format: Optional[OutputFormat] = "mp3_44100_128",

tests/test_tts.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22

3-
from elevenlabs import VoiceSettings, play
3+
from elevenlabs import VoiceSettings, play, Voice
44
from elevenlabs.client import AsyncElevenLabs, ElevenLabs
55

66
from .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+
2047
def test_tts_convert_with_voice_settings() -> None:
2148
"""Test TTS with custom voice settings."""
2249
client = ElevenLabs()

0 commit comments

Comments
 (0)