Skip to main content
Music & Speech Detection classifies what kind of sound is present across a clip: music, speech, both, or neither. Common uses are skipping hold music, gating a pipeline so only speech is processed downstream, and locating where a broadcast switches between talk and track. music_prob and speech_prob are independent, not a split of 100%. A singer over a backing track scores high on both at once. This is not AI Music Detection, which answers whether music was model-generated. See AI Music Detection.

Music & Speech Detection (batch)

Returns application/json. Every field is always present. Note that duration here is duration_s in seconds. Most other Modulate endpoints report duration_ms.

Try it

What you can configure

Audio formats

Accepted extensions: .aac, .flac, .m4a, .mp3, .mp4, .ogg, .opus, .wav. Maximum file size is 100 MB. Empty files are rejected with 400.

Music & Speech Detection (streaming)

One frame message per completed 192 ms window, then a done message carrying clip totals computed across everything received. Note that done reports duration_ms in milliseconds, where the batch response reports duration_s in seconds. Send audio as binary WebSocket frames of any size; the server buffers and windows internally. Send an empty text frame ("") to end the stream. The server then flushes remaining audio, delivers final frames, sends done, and closes.

Try it

WebSocket endpoints cannot be exercised with cURL. For command-line testing use websocat.

What you can configure

Audio formats

audio_format is required on every connection, including self-describing containers. Omitting it closes the connection with code 1003.
Streaming accepts a narrower set than batch. m4a, mp4, and opus are batch-only. Container formats. wav, mp3, ogg, flac, webm, aac, aiff. The stream carries sample rate and channel count, so sample_rate and num_channels must be omitted. Raw formats. s8, s16le, s16be, s24le, s24be, s32le, s32be, u8, u16le, u16be, u24le, u24be, u32le, u32be, f32le, f32be, f64le, f64be, mulaw, alaw. These are headerless, so sample_rate and num_channels are both required. sample_rate accepts 8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000. Common raw configurations: To convert a file to raw PCM:
Format parameters are validated at connection time, closing with 1003, and again while decoding, closing with 4002. The second catches undecodable audio and a mismatch between the declared audio_format and the bytes sent.

API reference