The output is always mono 16-bit PCM at 24 kHz, the same length as your input.
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
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_streamtakes 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=.
asyncio, generate_sync(...) and stream_sync(...)
take the same arguments.
Enhance a recording
Send amultipart/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.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 towss://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).
- Client → text
config:modelis required and must beclarity-1.taskisnoise_removalortarget_speaker_extraction.sample_rate_hzis 8000–48000. Fortarget_speaker_extraction, add"speaker_wav_b64": the speaker sample as a base64-encoded WAV file, 2–8 seconds. - Server → text
{"type": "ready", "sample_rate_hz": 24000, "encoding": "pcm_s16le"}. - Client → binary: mono 16-bit little-endian PCM at your declared rate, at most 1 second of audio per message.
- Server → binary: enhanced mono 16-bit little-endian PCM at 24 kHz, sent as it is produced.
- Client → text
{"type": "end"}. The server sends the remaining audio, then{"type": "done", "duration_s": <seconds>}, and closes with1000. 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_removalfirst if you only have a noisy recording.