Implementation:Elevenlabs Elevenlabs python VoiceSamplePreviewResponseModel
| Attribute | Value |
|---|---|
| Sources | src/elevenlabs/types/voice_sample_preview_response_model.py
|
| Domains | Voice Samples, Audio Preview |
| Last Updated | 2026-02-15 |
Overview
Description
The VoiceSamplePreviewResponseModel represents the response returned when previewing a specific voice sample in the ElevenLabs SDK. It provides the base64-encoded audio content of a sample associated with a particular voice, along with identifying information (voice ID, sample ID) and audio metadata (media type, duration).
Usage
This model is returned when requesting a preview of an individual voice sample. It ties together the voice identity (voice_id) and the specific sample (sample_id) with the audio data, allowing clients to play back or inspect sample audio without downloading the full file.
Code Reference
Source Location
src/elevenlabs/types/voice_sample_preview_response_model.py
Class Signature
class VoiceSamplePreviewResponseModel(UncheckedBaseModel):
...
Import Statement
from elevenlabs.types import VoiceSamplePreviewResponseModel
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. |
voice_id |
str |
Yes | The ID of the voice. |
sample_id |
str |
Yes | The ID of the sample. |
media_type |
str |
Yes | The media type of the audio. |
duration_secs |
Optional[float] |
No | The duration of the audio in seconds. |
Usage Examples
import base64
from elevenlabs import ElevenLabs
client = ElevenLabs(api_key="your_api_key")
# Preview a specific voice sample
preview = client.voices.get_sample_preview(
voice_id="voice_abc123",
sample_id="sample_xyz789"
)
print(f"Voice ID: {preview.voice_id}")
print(f"Sample ID: {preview.sample_id}")
print(f"Media Type: {preview.media_type}")
if preview.duration_secs:
print(f"Duration: {preview.duration_secs} seconds")
# Decode and save the audio preview
audio_data = base64.b64decode(preview.audio_base_64)
with open("sample_preview.mp3", "wb") as f:
f.write(audio_data)
Related Pages
- VoiceSample - Voice sample metadata model
- VoicePreviewResponseModel - Similar preview model for generated voice previews
- Voice - Parent voice model containing sample references