Implementation:Elevenlabs Elevenlabs python VoicePreviewResponseModel
| Attribute | Value |
|---|---|
| Sources | src/elevenlabs/types/voice_preview_response_model.py
|
| Domains | Voice Preview, Voice Design |
| Last Updated | 2026-02-15 |
Overview
Description
The VoicePreviewResponseModel represents the response returned when generating a voice preview in the ElevenLabs SDK. It contains the base64-encoded audio data of the preview, along with the generated voice ID that can be used to create a permanent voice from the preview. The model also includes metadata such as the media type, duration, and language of the generated preview.
Usage
This model is returned by voice preview/design endpoints where a user generates a new voice preview before committing to creating a permanent voice. The generated_voice_id field can be used in subsequent API calls to finalize the voice creation.
Code Reference
Source Location
src/elevenlabs/types/voice_preview_response_model.py
Class Signature
class VoicePreviewResponseModel(UncheckedBaseModel):
...
Import Statement
from elevenlabs.types import VoicePreviewResponseModel
Base Class
UncheckedBaseModel (from elevenlabs.core.unchecked_base_model)
I/O Contract
| Field | Type | Required | Description |
|---|---|---|---|
audio_base_64 |
str |
Yes | The base64 encoded audio of the preview. |
generated_voice_id |
str |
Yes | The ID of the generated voice. Use it to create a voice from the preview. |
media_type |
str |
Yes | The media type of the preview (e.g., audio/mpeg). |
duration_secs |
float |
Yes | The duration of the preview in seconds. |
language |
Optional[str] |
No | The language of the preview. |
Usage Examples
import base64
from elevenlabs import ElevenLabs
client = ElevenLabs(api_key="your_api_key")
# Generate a voice preview (hypothetical endpoint usage)
preview = client.voice_design.generate_preview(
text="Hello, this is a voice preview.",
voice_description="A warm and friendly male voice",
language="en"
)
print(f"Generated Voice ID: {preview.generated_voice_id}")
print(f"Media Type: {preview.media_type}")
print(f"Duration: {preview.duration_secs} seconds")
print(f"Language: {preview.language}")
# Decode and save the audio preview
audio_data = base64.b64decode(preview.audio_base_64)
with open("preview.mp3", "wb") as f:
f.write(audio_data)
Related Pages
- Voice - The full voice model that can be created from a preview
- VoiceSamplePreviewResponseModel - Similar preview model for voice samples