# Sound event detection (https://docs.cochl.ai/docs/pro/sound-event-detection)



**Sound event detection (SED)** identifies the sound events present in an audio file—sirens, gunshots, baby cries, glass breaks, and over 100 other categories. SED is the core capability of Cochl.Sense and is available in both Cochl.Sense Pro and Cochl.Sense Core.

This page covers SED via **Cochl.Sense Pro**. For on-device detection, see [Cochl.Sense Core → sound event detection](https://docs.cochl.ai/docs/core/sound-event-detection).

## 1. How it works [#1-how-it-works]

When you upload a file, the API runs a sliding-window classifier and returns the detected events per window. With the standard model, each window is **2 seconds** long and a new window starts **every second**, so consecutive windows overlap by 1 second (`0–2 s`, `1–3 s`, `2–4 s`, …). For each window, the API returns the time interval and the sound classes whose confidence passed that tag’s detection threshold.

* A window in which no class passed its threshold is **left out** of the results, so the list can have gaps.
* A trailing piece of audio shorter than a full window isn’t analyzed, and a file shorter than one window (2 s) can’t be analyzed at all — the service returns an error ([details](https://docs.cochl.ai/docs/pro/error-codes#max-workers-must-be-greater-than-0)).
* Because windows overlap, **don’t add up window durations** to estimate how long a sound lasted — a 3-second siren shows up in about four 2-second windows.

<Callout type="info" title="Pick the tags, and how sensitive each one is">
  You don’t have to take every tag at its default. In each request you can **keep only the tags you need** (`sound_event_tags`) and **set a detection threshold per tag** (`sound_event_thresholds`): a lower threshold catches more of a sound, a higher one catches less. Both work from the Dashboard and from the API — see [Keep only some tags](#keep-only-some-tags) and [Adjust detection thresholds](#adjust-detection-thresholds).
</Callout>

<img src="/images/dashboard-sound-event.png" alt="A Sound event detection result in the Dashboard: each detected tag on a timeline under the audio player" />

The model recognizes **100+ tags across eight categories**. The example above shows Speech detection; the full catalog covers everything from sirens and gunshots to vacuum cleaners and bird chirps. A taste of what each category covers:

<Cards>
  <Card title="&#x22;Emergency&#x22;" description="&#x22;Siren · Gunshot · Glass_break&#x22;" href="/docs/pro/sound-event-detection/sound-tags#emergency" />

  <Card title="&#x22;Human action&#x22;" description="&#x22;Applause · Clap · Footstep&#x22;" href="/docs/pro/sound-event-detection/sound-tags#human-action" />

  <Card title="&#x22;Human status&#x22;" description="&#x22;Baby_cry · Cough · Snore&#x22;" href="/docs/pro/sound-event-detection/sound-tags#human-status" />

  <Card title="&#x22;Human speech&#x22;" description="&#x22;Speech · Whisper · Yell&#x22;" href="/docs/pro/sound-event-detection/sound-tags#human-speech" />

  <Card title="&#x22;Home context&#x22;" description="&#x22;Vacuum_cleaner · Knock · Cooking&#x22;" href="/docs/pro/sound-event-detection/sound-tags#home-context" />

  <Card title="&#x22;Outdoor context&#x22;" description="&#x22;Car_horn · Car_alarm · Aircraft_noise&#x22;" href="/docs/pro/sound-event-detection/sound-tags#outdoor-context" />

  <Card title="&#x22;Animal&#x22;" description="&#x22;Dog_bark · Cat_meow · Bird_chirp&#x22;" href="/docs/pro/sound-event-detection/sound-tags#animal" />

  <Card title="&#x22;Music&#x22;" description="&#x22;Guitar · Piano · Drum&#x22;" href="/docs/pro/sound-event-detection/sound-tags#music" />

  <Card title="&#x22;Browse all&#x22;" description="&#x22;100+ tags →&#x22;" href="/docs/pro/sound-event-detection/sound-tags" />
</Cards>

For the complete list, see [Sound tags](https://docs.cochl.ai/docs/pro/sound-event-detection/sound-tags).

## 2. Detecting sound events with Python [#2-detecting-sound-events-with-python]

Use &#x2A;*`cochl.sense.IntegratedApi`**—the multi-feature client. It returns SED in the unified Integration API shape (`classes[]` / `confidence`), and can run [speech analysis](https://docs.cochl.ai/docs/pro/speech-analysis) and [audio insights](https://docs.cochl.ai/docs/pro/audio-insights) in the same call.

<Callout type="warn">
  The older single-feature &#x2A;*`cochl.sense.Client`** (SED-only, legacy `tags[]` / `probability` shape) was **removed in `cochl` 2.0.2**. On the current library, `from cochl.sense import Client` raises `ImportError`. If you still have `Client` code, see [Legacy `Client` (removed in 2.0.2)](#legacy-client-deprecated) below for the migration mapping.
</Callout>

Make sure you’ve completed [Getting started](https://docs.cochl.ai/docs/pro/getting-started)—you need a project key and the `cochl` Python library installed.

```python
from cochl.sense import IntegratedApi, IntegratedApiOptions

api = IntegratedApi('YOUR_API_PROJECT_KEY')

job = api.analyze_file(
    'your_file.wav',
    IntegratedApiOptions(
        sound_event_detection=True,
        speech_analysis=False,  # the service flags default to True,
        audio_insights=False,   # so turn off the ones you don't want
    ),
)

result = api.get_completed_result(job['job_id'])
for chunk in result['sound_event_detection']['results']:
    # classes[] isn't sorted by confidence — pick the highest yourself
    top = max(chunk['classes'], key=lambda c: c['confidence'])
    print(f"[{chunk['start_time_sec']:.2f}–{chunk['end_time_sec']:.2f}] "
          f"{top['class']} ({top['confidence']:.2f})")
```

Running this on a short baby-monitor clip prints something like:

```text
[0.00–2.00] Baby_cry (0.92)
[1.00–3.00] Baby_cry (0.88)
[2.00–4.00] Speech (0.74)
[3.00–5.00] Speech (0.81)
[5.00–7.00] Baby_cry (0.61)
```

There is no `4.00–6.00` line: nothing in that window passed its threshold, so the API left it out.

And the `result` dict it came from:

```json
{
  "sound_event_detection": {
    "status": "success",
    "results": [
      {
        "start_time": "00:00.00",
        "end_time": "00:02.00",
        "start_time_sec": 0.0,
        "end_time_sec": 2.0,
        "classes": [
          { "class": "Speech",   "confidence": 0.41 },
          { "class": "Baby_cry", "confidence": 0.92 }
        ]
      },
      {
        "start_time": "00:01.00",
        "end_time": "00:03.00",
        "start_time_sec": 1.0,
        "end_time_sec": 3.0,
        "classes": [
          { "class": "Baby_cry", "confidence": 0.88 }
        ]
      }
    ]
  }
}
```

`classes` lists only the tags that passed their thresholds, in the model’s tag order rather than by confidence — the first entry isn’t necessarily the most confident one. The result also carries a top-level `metadata` object and an `id` on each window and class; see [Getting Started → Example response](https://docs.cochl.ai/docs/pro/getting-started#example-response-abbreviated).

Set `speech_analysis=True` in the same `IntegratedApiOptions` call to also transcribe speech, or `audio_insights=True` to add a summary. Speech analysis and audio insights are free for now — see [Getting Started → Valid service combinations](https://docs.cochl.ai/docs/pro/getting-started#4-valid-service-combinations) and [Usage & pricing](https://docs.cochl.ai/docs/pro/getting-started#5-usage--pricing).

### Keep only some tags [#keep-only-some-tags]

If you only care about a few sounds, list them in `sound_event_tags` and the result keeps just those tags. Use the exact names from [Sound tags](https://docs.cochl.ai/docs/pro/sound-event-detection/sound-tags); they are case-sensitive.

```python
options = IntegratedApiOptions(
    sound_event_detection=True,
    speech_analysis=False,
    audio_insights=False,
)
options.sound_event_tags = ['Glass_break', 'Scream']  # only these tags in the result

job = api.analyze_file('your_file.wav', options)
```

Over plain HTTP, add the same key to the `options` JSON: `{"sound_event_detection": true, ..., "sound_event_tags": ["Glass_break", "Scream"]}`.

* The model still analyzes every tag, so the cost is the same and [audio insights](https://docs.cochl.ai/docs/pro/audio-insights) still sees every sound. Only the `sound_event_detection` result is filtered.
* A window with none of your tags is left out, like any window where nothing passed its threshold, so `classes` is never empty.
* A name the model doesn’t know returns `400` with a suggestion, for example `Glass_brake (did you mean Glass_break?)` ([details](https://docs.cochl.ai/docs/pro/error-codes#unknown-sound-event-tags)). Leave `sound_event_tags` out to get every tag.

**On the Dashboard:** on the **Sound event detection** page, click **Choose tags** next to **Sound tags**, pick the tags and click **Done**. The **Run this from your code** panel under the result (also **Export → Get code**) then shows the same request with `sound_event_tags` filled in.

### Adjust detection thresholds [#adjust-detection-thresholds]

Every tag has a default detection threshold: a window reports the tag only when its confidence is above it. To catch more of a sound, lower its threshold; to catch less, raise it. Change it per request with `sound_event_thresholds`; tags you don’t list keep their defaults.

```python
options.sound_event_thresholds = {'Glass_break': 0.3, 'Speech': 0.8}
```

The defaults depend on the model your project uses, so read them from the API rather than hard-coding them:

```bash
curl -s https://integration.cochl.ai/api/v1/tags -H "X-Api-Key: $COCHL_KEY"
# {"model": "...", "tags": [{"name": "Glass_break", "threshold": 0.5}, ...]}
```

Each result names the model in `metadata.sound_event_model`. When your project moves to a new model, its defaults can change, so review any thresholds you set. Values must be between 0 and 1, and an unknown tag name returns `400` with a suggestion ([details](https://docs.cochl.ai/docs/pro/error-codes#unknown-sound-event-thresholds)).

**On the Dashboard:** on the **Sound event detection** page, click **Edit** next to **Sensitivity**, pick a tag and enter its threshold (0 to 1); the box starts at the tag’s default for your project’s model. **Run this from your code** includes the thresholds as `sound_event_thresholds`.

<Card title="&#x22;cochlearai/cochl-sense-py&#x22;" description="&#x22;More runnable sample scripts.&#x22;" href="https://github.com/cochlearai/cochl-sense-py" />

<Accordions>
  <Accordion title="<>Legacy <code>Client</code> (removed in 2.0.2)</>" value="legacy-client" id="legacy-client-deprecated">
    The original single-feature &#x2A;*`cochl.sense.Client`** returned SED-only results in the legacy `tags[]` / `probability` shape. It was removed in `cochl` **2.0.2**, together with `APIConfig` and `APIConfigFromJson`; the last version that includes it is **2.0.1** (`pip install "cochl==2.0.1"`). Move to [`IntegratedApi`](#2-detecting-sound-events-with-python). The snippet below is only here to help you recognize and migrate old code:

    ```python
    import cochl.sense as sense
    from cochl.sense import Result

    api_config = sense.APIConfigFromJson('./config.json')
    client = sense.Client(
        'YOUR_API_PROJECT_KEY',
        api_config=api_config,
    )
    result: Result = client.predict('your_file.wav')

    print(result.events.to_dict(api_config))
    ```

    `to_dict()` returns the session id and one entry per window, with times as float seconds:

    ```json
    {
      "session_id": "df1637ab-5478-455c-bff8-c7b90ff215c2",
      "window_results": [
        {
          "start_time": 3.0,
          "end_time": 5.0,
          "sound_tags": [
            { "name": "Baby_cry", "probability": 0.92 }
          ]
        }
      ]
    }
    ```

    For a summarized, human-readable form, `events_summarized()` merges consecutive windows per tag and returns a **string**, one line per detection (for example `At 3.0-7.0s, [Baby_cry] was detected`):

    ```python
    print(result.events_summarized(api_config))
    ```

    **Migrating to `IntegratedApi`** — the field rename pattern:

    | Legacy `Client` shape                       | Integration API shape                                                                                                                                 |
    | ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `window_results[]` (one per window)         | `sound_event_detection.results[]` (one per window that has a detection)                                                                               |
    | `window_results[].sound_tags[].name`        | `results[].classes[].class`                                                                                                                           |
    | `window_results[].sound_tags[].probability` | `results[].classes[].confidence`                                                                                                                      |
    | `start_time` / `end_time` (float seconds)   | `start_time_sec` / `end_time_sec` (float seconds), plus display strings `start_time` / `end_time` (`MM:SS.SS`, or `HH:MM:SS.SS` from the 1-hour mark) |
    | `session_id`                                | `job_id` (returned by `analyze_file`)                                                                                                                 |
    | `events_summarized()` (a string)            | No equivalent — build your own summary from `results[]`                                                                                               |
  </Accordion>
</Accordions>

## 3. Training your own sound events [#3-training-your-own-sound-events]

Cochl.Sense Pro uses our built-in tag list only. If you need to train a custom sound tag, that’s available exclusively on Cochl.Sense Core—see [Cochl.Sense Core → Custom sound: Sound events](https://docs.cochl.ai/docs/core/sound-event-detection/custom-sound).

Cochl.Sense Pro supports a different kind of customization—[Custom sound: Speaker profile](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile), for identifying specific voices in [speech analysis](https://docs.cochl.ai/docs/pro/speech-analysis) results.

## 4. Combine with other analyses [#4-combine-with-other-analyses]

On the Dashboard, each service has its own page and runs on its own: the **Sound event detection** page runs SED only, and the **Audio insights** page runs audio insights only. To run SED in the same request as [speech analysis](https://docs.cochl.ai/docs/pro/speech-analysis) or [audio insights](https://docs.cochl.ai/docs/pro/audio-insights), use the API or the Python library. Only sound event detection is billed, and only if it succeeds; speech analysis and audio insights are free for now (see [Usage & pricing](https://docs.cochl.ai/docs/pro/getting-started#5-usage--pricing)); through the API you can turn on any combination of the three, for example, sound event detection and audio insights without speech analysis ([Valid service combinations](https://docs.cochl.ai/docs/pro/getting-started#4-valid-service-combinations)).

On the **Sound event detection** page, the result has two tabs:

* **Sound Events**—per-window timeline and per-tag detections
* **JSON**—the full result as returned by the API

The **Export** menu above the result copies the JSON (**Copy JSON**), downloads it (&#x2A;*Result (JSON)**) or the detections as a spreadsheet (&#x2A;*Sound Events (CSV)**), and opens **Get code**, the same request for your own code.
