ElevenLabs sound effects: generate a sound from a text prompt.

Values

BODY_FIELDS

BODY_FIELDS: Vec [
  "duration_seconds",
  "prompt_influence",
  "loop",
  "model_id"
]

Functions

sound-effect

fn (text: Str): Bytes
fn (text: Str, options: Map): Bytes
fn (text: Str, options: Map, opts: Map): Bytes

POST /v1/sound-generation: generate a sound effect from a text prompt. Returns audio Bytes (mp3 by default). options: duration_seconds (0.5-30; the model picks when unset), prompt_influence (0-1, default 0.3), loop (seamless loop), model_id ("eleven_text_to_sound_v2" default, or "eleven_text_to_sound_v3"), output_format.

Example

audio ::elevenlabs::sound/sound-effect("Glass shattering on a tile floor", {duration_seconds: 2.5})
::hot::file/write-file-bytes("glass.mp3", audio)
Context Vars: elevenlabs.api.key

sound-effect-body

fn (text: Str, options: Map): Map

The JSON body for sound-effect: text plus the body fields present in options (nulls omitted). Exposed for testing.

Example

::elevenlabs::sound/sound-effect-body("Rain", {duration_seconds: 2.5, output_format: "pcm_16000"})
// {text: "Rain", duration_seconds: 2.5}

sound-effect-path

fn (options: Map): Str

/v1/sound-generation plus the query params (output_format, enable_logging) present in options. Exposed for testing.

Example

::elevenlabs::sound/sound-effect-path({output_format: "pcm_16000"})  // "/v1/sound-generation?output_format=pcm_16000"
::elevenlabs::sound/sound-effect-path({})  // "/v1/sound-generation"