Skip to main content
Speech enhancement cleans up recorded or live speech. It does one of two tasks: The output is always mono 16-bit PCM at 24 kHz, the same length as your input.
Speech enhancement is available in preview. It is not yet intended for production workloads, and the interface may still change.
All requests need an API key; see Authentication. Your organization also needs access to clarity-1.

Billing

Enhancement is billed per second of input audio processed, rounded up to the next whole second, with a one-second minimum per request. A stream that disconnects early is billed for the audio processed up to that point. A request that fails with an error is not billed.

Python SDK

To keep one voice, pass speaker=load_audio("speaker.wav"). load_audio takes a path or WAV bytes in any supported format. The result has .audio (PCM16 bytes), .sample_rate (24000), .duration (seconds), .wav (WAV bytes) and .save(path).

Real-time

  • Add speaker=load_audio("speaker.wav") to keep one voice.
  • load_audio_stream takes a path or WAV bytes: a 16-bit WAV (stereo is mixed down).
  • Any iterable or async iterable of 16-bit mono PCM chunks also works with sample_rate=.
For plain scripts without asyncio, generate_sync(...) and stream_sync(...) take the same arguments.

Enhance a recording

Send a multipart/form-data upload.
string
required
clarity-1. Any other value is rejected.
file
required
The recording, as a WAV file. At most 300 seconds, and at most 64 MB for the whole request.
string
default:"noise_removal"
noise_removal or target_speaker_extraction.
file
Required for target_speaker_extraction, rejected for noise_removal. A WAV sample of the person to keep, 2–8 seconds long. See A good speaker sample.
Accepted WAV formats for both file and speaker: 16-, 24- or 32-bit integer PCM, or 32-bit float; mono or stereo (stereo is mixed down to mono); sample rates from 8 kHz to 48 kHz. Response 200: an audio/wav body, mono 16-bit PCM at 24 kHz, the same duration as the input. The X-Audio-Duration-Seconds header carries that duration.

Errors

Errors return the standard JSON error body; see Error Codes.

Enhance live audio

Connect to wss://api.kugelaudio.com/v1/audio/enhance/stream and authenticate in the handshake, as for any WebSocket (Authentication). A missing or invalid key is refused during the handshake with HTTP 401, before the connection opens. Access, credits and rate limits are checked after the config message; a refusal arrives as an error message followed by a close code (below).
  1. Client → text config:
    model is required and must be clarity-1. task is noise_removal or target_speaker_extraction. sample_rate_hz is 8000–48000. For target_speaker_extraction, add "speaker_wav_b64": the speaker sample as a base64-encoded WAV file, 2–8 seconds.
  2. Server → text {"type": "ready", "sample_rate_hz": 24000, "encoding": "pcm_s16le"}.
  3. Client → binary: mono 16-bit little-endian PCM at your declared rate, at most 1 second of audio per message.
  4. Server → binary: enhanced mono 16-bit little-endian PCM at 24 kHz, sent as it is produced.
  5. Client → text {"type": "end"}. The server sends the remaining audio, then {"type": "done", "duration_s": <seconds>}, and closes with 1000. The total output matches your input’s duration.

Errors and close codes

On an error the server sends {"type": "error", "code": "<error_code>", "message": "..."} and then closes the connection.

A good speaker sample

target_speaker_extraction only works as well as the sample you give it.
  • 2–8 seconds of speech. Shorter or longer samples are rejected.
  • That person alone. No one else talking, not even briefly.
  • Little background noise. A quiet room is best; clean it up with noise_removal first if you only have a noisy recording.
Last modified on September 23, 2026