Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Elevenlabs Elevenlabs python VoiceSample

From Leeroopedia
Attribute Value
Sources src/elevenlabs/types/voice_sample.py
Domains Voice Management, Audio Samples
Last Updated 2026-02-15

Overview

Description

The VoiceSample model represents metadata for an audio sample associated with a voice in the ElevenLabs SDK. Each voice can have multiple samples used for voice cloning and training. This model captures file information (name, MIME type, size, hash), audio properties (duration, trimming), and processing flags (background noise removal, audio isolation, speaker separation).

Usage

The VoiceSample model appears as items within the samples list field on the Voice model. It is used to describe audio files that have been uploaded for voice cloning or fine-tuning purposes. The model is frozen (immutable) and allows extra fields for forward compatibility.

Code Reference

Source Location

src/elevenlabs/types/voice_sample.py

Class Signature

class VoiceSample(UncheckedBaseModel):
    ...

Import Statement

from elevenlabs.types import VoiceSample

Base Class

UncheckedBaseModel (from elevenlabs.core.unchecked_base_model)

I/O Contract

Field Type Required Description
sample_id Optional[str] No The ID of the sample.
file_name Optional[str] No The name of the sample file.
mime_type Optional[str] No The MIME type of the sample file.
size_bytes Optional[int] No The size of the sample file in bytes.
hash Optional[str] No The hash of the sample file.
duration_secs Optional[float] No The duration of the sample in seconds.
remove_background_noise Optional[bool] No Whether background noise removal was applied.
has_isolated_audio Optional[bool] No Whether isolated audio is available.
has_isolated_audio_preview Optional[bool] No Whether an isolated audio preview is available.
speaker_separation Optional[SpeakerSeparationResponseModel] No Speaker separation information for the sample.
trim_start Optional[int] No The start trim point of the sample.
trim_end Optional[int] No The end trim point of the sample.

Usage Examples

from elevenlabs import ElevenLabs

client = ElevenLabs(api_key="your_api_key")

# Access voice samples through a Voice object
voice = client.voices.get(voice_id="voice_abc123")

if voice.samples:
    for sample in voice.samples:
        print(f"Sample ID: {sample.sample_id}")
        print(f"File: {sample.file_name} ({sample.mime_type})")
        print(f"Size: {sample.size_bytes} bytes")
        print(f"Duration: {sample.duration_secs} seconds")

        if sample.has_isolated_audio:
            print("Isolated audio available")
        if sample.remove_background_noise:
            print("Background noise removal applied")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment