# Getting started (https://docs.cochl.ai/docs/pro/getting-started)



**Cochl.Sense Pro** analyzes pre-recorded audio files for sound events, speech, and high-level scene insights. It accepts MP3, WAV, FLAC, and OGG files, and converts most other audio formats (such as MP4 or M4A) on the server, so you usually don’t need a conversion step.

<Callout type="info">
  Cochl.Sense Pro was previously called Cochl.Sense Cloud API.
</Callout>

<Callout type="info" title="Prerequisites">
  * **Python 3.10 or higher.**
  * **A Cochl.Sense Dashboard account** — sign up or log in at [dashboard.cochl.ai](https://dashboard.cochl.ai/). You’ll create a Cochl.Sense Pro project and copy its project key in [step 2](#2-get-your-project-key).
</Callout>

## 1. Set up your Python environment [#1-set-up-python-environment]

Cochl.Sense Pro can be easily integrated into any Python application using the [Cochl library](https://pypi.org/project/cochl/). The library supports Python 3.10 or higher. First, create a Python virtual environment.

<Tabs groupId="os" items="[&#x22;macOS / Linux&#x22;,&#x22;Windows&#x22;]">
  <Tab value="&#x22;macOS / Linux&#x22;">
    ```
    python3 -m venv venv
    . venv/bin/activate
    pip install --upgrade pip
    pip install --upgrade cochl

    git clone https://github.com/cochlearai/cochl-sense-py.git
    cd cochl-sense-py/samples
    ```
  </Tab>

  <Tab value="&#x22;Windows&#x22;">
    ```
    python -m venv venv
    .\venv\Scripts\activate
    pip install --upgrade pip
    pip install --upgrade cochl

    git clone https://github.com/cochlearai/cochl-sense-py.git
    cd cochl-sense-py/samples
    ```
  </Tab>
</Tabs>

<Callout type="info">
  Use `cochl` **2.0.2 or later** (`pip install --upgrade cochl` installs the latest). Since 2.0.2 the library sends your project key when it reads a job’s progress stream, which `get_completed_result()` depends on; older versions don’t.
</Callout>

## 2. Get your project key [#2-get-your-project-key]

Every request is authenticated with a project key. Sign up or log in at the [Cochl.Sense Dashboard](https://dashboard.cochl.ai/), then:

1. Open **Projects** in the sidebar, click **New project**, enter a project name, and click **Create project**. (A new account already has a **Default project** you can use as is.)

   <img src="/images/pro/getting-started/create-project.png" alt="The New project dialog on the Cochl.Sense Dashboard, which asks only for a project name" width="560" />

2. Open the project. Its home shows the key under **Call it from your app**: click the copy icon, or the eye icon to reveal it. The same key is under the project’s **Settings**, and the **Get started** button at the top right walks through the first call with code you can run as pasted ([Dashboard → Overview](https://docs.cochl.ai/docs/pro/dashboard#1-overview)).

   <img src="/images/pro/getting-started/copy-project-key.png" alt="The Call it from your app card on a Cochl.Sense Pro project’s Overview: the masked project key with its reveal and copy icons, the code in cURL, Python and Node.js, and Copy agent prompt" width="400" />

<Callout type="warn">
  Don’t share your project key with anyone outside your project or team.
</Callout>

Project keys **don’t expire**. If you need to rotate one, click **Reset key** in the project’s **Settings** on the Dashboard. The new key works right away, and the old one stops working at the same time — update your apps before you reset.

## 3. Run the example [#3-run-the-example]

* Supported file formats for Cochl.Sense Pro: MP3, WAV, FLAC, and OGG. The Dashboard’s service pages (**Sound event detection**, **Speech analysis** and **Audio insights** under **Project** in the sidebar) take the same four formats, and can also record from your microphone (up to **30 seconds** per take) or run one of the built-in sample clips. Through the API and the Python library, files in other formats (for example MP4 or M4A) are converted on the server with FFmpeg; a file that can’t be decoded is rejected with `400` ([decode failure](https://docs.cochl.ai/docs/pro/error-codes#audio-decode-failure)).
* Audio can be up to **59 minutes** long per request; a longer file is rejected with `400` ([audio too long](https://docs.cochl.ai/docs/pro/error-codes#audio-too-long)). `get_completed_result()` waits at most **10 minutes** and returns `None` if the job hasn’t finished by then (the job itself keeps running) — see [Rate limits & audio length](https://docs.cochl.ai/docs/pro/error-codes#7-rate-limits--audio-length). Files must be at least **2 seconds** long for sound event detection. An organization can have **1** job in progress at a time on the trial and **10** on paid plans; another request meanwhile gets `429` ([REST API → Limits](https://docs.cochl.ai/docs/pro/rest-api#6-limits)).

If the Dashboard won’t take your file, or the API rejects it as undecodable, convert it first — see [Convert to supported file formats](#1-convert-to-supported-file-formats-mp3-wav-flac-ogg).

You can use any audio file of your own. To try it with a ready-made clip, download `sample_male_speech.wav` into the `samples` folder you’re in. The `cochl-sense-py` repository no longer ships audio files on its `main` branch, so this link points to the commit where the clip was last published ([`c08a010`](https://github.com/cochlearai/cochl-sense-py/tree/c08a01060d6a12e25babc2e88bd28b787eb85d65/samples)):

```bash
curl -LO https://raw.githubusercontent.com/cochlearai/cochl-sense-py/c08a01060d6a12e25babc2e88bd28b787eb85d65/samples/sample_male_speech.wav
```

On Windows PowerShell, type `curl.exe` instead of `curl`.

This simple setup is enough to upload your file and run analyses. Using the `IntegratedApi`, you can run sound event detection, speech analysis, and audio insights in a single upload. Replace “YOUR\_API\_PROJECT\_KEY” with your project key.

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

api = IntegratedApi('YOUR_API_PROJECT_KEY')

job = api.analyze_file(
    'sample_male_speech.wav',  # or the path to your own file
    IntegratedApiOptions(
        sound_event_detection=True,
        speech_analysis=True,
        audio_insights=True,
    ),
)

result = api.get_completed_result(job['job_id'])
# result['sound_event_detection'] — SED chunks
# result['speech_analysis']       — speech analysis segments
# result['audio_insights']        — audio insights summary
print(result)
```

The same flow ships as a runnable script, [`sample_audio_insights.py`](https://github.com/cochlearai/cochl-sense-py/blob/main/samples/sample_audio_insights.py), in the `samples` folder you cloned. Replace `'YOUR_API_PROJECT_KEY'` and `'your_file.wav'` in it (for example with `'sample_male_speech.wav'`), then run:

```bash
python sample_audio_insights.py
```

[`sample_sound_event_detection.py`](https://github.com/cochlearai/cochl-sense-py/blob/main/samples/sample_sound_event_detection.py) and [`sample_speech_analysis.py`](https://github.com/cochlearai/cochl-sense-py/blob/main/samples/sample_speech_analysis.py) do the same with a single service enabled.

## 4. Valid service combinations [#4-valid-service-combinations]

The three services are independent: turn on **any combination**, as long as at least one is on. Turning all three off returns `400` ([No services selected](https://docs.cochl.ai/docs/pro/error-codes#no-services-selected)).

* **Audio insights can run on its own.** The server analyzes sound events and speech internally to write the summary, but returns them only if you turn them on too.
* Over the REST API, only sound event detection is on by default; turn on speech analysis and audio insights when you need them ([REST API → Options](https://docs.cochl.ai/docs/pro/rest-api#5-options)).
* **The Python library (`cochl` 2.0.3) is different:** the three service flags of `IntegratedApiOptions` default to `True`, so `IntegratedApiOptions()` runs all three (only sound event detection is billed). Pass `False` for each service you don’t want — for example, `IntegratedApiOptions(speech_analysis=False, audio_insights=False)` runs sound event detection only.

You’re billed for sound event detection when you turn it on and it succeeds; speech analysis and audio insights are free for now ([Usage & pricing](#5-usage--pricing)).

Sound event detection also takes two optional settings: `sound_event_tags` returns only the tags you list, and `sound_event_thresholds` sets a detection threshold per tag (lower catches more, higher catches less). See [sound event detection → Keep only some tags](https://docs.cochl.ai/docs/pro/sound-event-detection#keep-only-some-tags) and [Adjust detection thresholds](https://docs.cochl.ai/docs/pro/sound-event-detection#adjust-detection-thresholds); the Dashboard sets both under **Sound tags** in the run settings.

### Example response (abbreviated) [#example-response-abbreviated]

An illustrative `result` for an interview recording, with all three services enabled, shortened to the first few items of each list. It is not the output for `sample_male_speech.wav`; your values will differ.

```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": "Male_speech", "confidence": 0.81 },
          { "class": "Speech",      "confidence": 0.94 }
        ]
      },
      {
        "start_time": "00:01.00",
        "end_time": "00:03.00",
        "start_time_sec": 1.0,
        "end_time_sec": 3.0,
        "classes": [
          { "class": "Male_speech", "confidence": 0.88 }
        ]
      }
    ]
  },
  "speech_analysis": {
    "status": "success",
    "results": [
      {
        "speaker": "SPEAKER_00",
        "speaker_name": "Unknown 0",
        "speaker_score": 0.08,
        "transcript": "So, growing up, your father had a really strong influence on you.",
        "start_time": "00:00.00",
        "end_time": "00:04.32",
        "start_time_sec": 0.0,
        "end_time_sec": 4.32
      },
      {
        "speaker": "SPEAKER_01",
        "speaker_name": "Christian_Bale",
        "speaker_score": 0.41,
        "transcript": "Yeah, he taught me to never settle for the obvious choice.",
        "start_time": "00:04.60",
        "end_time": "00:08.91",
        "start_time_sec": 4.6,
        "end_time_sec": 8.91
      }
    ]
  },
  "audio_insights": {
    "status": "success",
    "result": {
      "contains_speech": true,
      "detected_language": "en",
      "primary_sound_environment": "Speech-dominated, likely an interview",
      "situation_summary": "The audio captures an interview where Christian Bale reflects on his father's influence and his approach to acting.",
      "notable_events": ["Male_speech", "Speech"],
      "speech_content_summary": "Bale credits his father for teaching him to look past obvious choices when picking roles.",
      "keywords": ["Christian Bale", "father", "upbringing", "acting"]
    }
  },
  "metadata": {
    "audio": {
      "input": {
        "filename": "interview.wav", "format": "wav", "size_bytes": 5292044,
        "sample_rate_hz": 44100, "channels": 2, "content_type": "audio/wav"
      },
      "processed": {
        "sample_rate_hz": 44100, "channels": 1, "encoding": "float32_pcm",
        "resampled": false, "downmixed": true
      }
    },
    "warnings": ["Input audio was downmixed to mono before processing."]
  }
}
```

A few things to notice:

* **`sound_event_detection.results[]`** has one entry per 2-second inference window, and a new window starts every second, so windows overlap. Windows where nothing was detected are left out, and `classes[]` isn’t sorted by confidence. Don’t add up window durations to measure how long a sound lasted — see [sound event detection → How it works](https://docs.cochl.ai/docs/pro/sound-event-detection#1-how-it-works).
* **`speech_analysis.results[]`** has one segment per speaker turn — variable length.
* **`audio_insights.result`** is one object for the whole file (no time chunks). `detected_language` is a lowercase ISO 639-1 code (`"en"`, or `"en,ko"` for several), and is `"N/A"` when there is no speech.
* **`metadata`*&#x2A; describes the audio as received and as processed, and lists any &#x2A;*`warnings`** (for example, resampling, downmixing to mono, a `speech_lang` that wasn’t applied, or an input that is nearly silent, very quiet, clipped or recorded below 16 kHz — see [Input warnings](#input-warnings)). `metadata.sound_event_model` (present when sound event detection is on) names the model that scored the sound events. It’s also the first event on the progress stream.
* **`speaker_name: "Christian_Bale"`** appears because a profile with that name was registered via [Custom sound: Speaker profile](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile), and `speaker_score` is the similarity against that profile. Unmatched turns get `Unknown <n>` (numbered to match the diarization label in `speaker`, e.g. `SPEAKER_00` → `Unknown 0`) with the closest profile's score, which is `-1.0` when the organization has no registered profiles. Organizations without speaker recognition can’t register profiles, so every turn comes back as `Unknown <n>` — see [speech analysis](https://docs.cochl.ai/docs/pro/speech-analysis#when-speaker_name-is-missing).
* Result items also carry identifiers (`id` on SED windows and classes, `item_ids` on speech segments and audio insights) used for result feedback. They’re omitted above, and you can ignore them.

#### Input warnings [#input-warnings]

While decoding, the API measures the level of your audio and reports it in `metadata.audio.level` (`peak_dbfs`, `rms_dbfs`, `active_rms_dbfs`, `silent_ratio`, `clipped_ratio`). When the input is likely to hurt detection, a plain-language note is added to `metadata.warnings`. The request still runs.

| You’ll see a warning when                                        | What to do                                                          |
| ---------------------------------------------------------------- | ------------------------------------------------------------------- |
| The loudest point of the audio is below −60 dBFS (nearly silent) | Check the recording; few or no sounds can be detected.              |
| The loudest point is below −50 dBFS (very quiet)                 | Record closer to the source or raise the input gain.                |
| More than 1% of samples are at full scale (clipped)              | Lower the input gain; distortion causes missed or wrong detections. |
| The file was recorded below 16 kHz                               | Use 16 kHz or higher if you can.                                    |

#### Time format [#time-format]

Every result item carries both a numeric `start_time_sec` / `end_time_sec` (float seconds) and a human-readable `start_time` / `end_time` string. The string format is chosen for each value separately, so a long file mixes both:

* **Before the 1-hour mark** — `MM:SS.SS` (e.g. `"05:32.10"`).
* **From the 1-hour mark on** — `HH:MM:SS.SS` (e.g. `"01:01:58.52"`).

Always parse `start_time_sec` / `end_time_sec` for math; the string fields are for display only.

`IntegratedApi` returns a different (Integration API) result shape than the legacy `Client`, which was removed in `cochl` 2.0.2. If you’re migrating older code, see the field mapping under [Legacy `Client` (removed in 2.0.2)](https://docs.cochl.ai/docs/pro/sound-event-detection#legacy-client-deprecated) in sound event detection.

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


<div id="6-usage--pricing" style="{ scrollMarginTop: '6rem' }" />

## 5. Usage & pricing [#5-usage--pricing]

Cochl.Sense Pro is billed by the length of the analyzed audio. For now only sound event detection is billed; speech analysis and audio insights are free. Length is counted per job **by the second, rounded up** — a 2.2-second file counts as 3 seconds, a 16-second file as 16.

| Service               | Price                                               |
| --------------------- | --------------------------------------------------- |
| Sound event detection | **$0.012*&#x2A; per minute (**$0.0002** per second) |
| Speech analysis       | **Free**                                            |
| Audio insights        | **Free**                                            |

When you combine services in a single request, only sound event detection is billed — all three together cost **$0.012** per minute, the same as sound event detection alone. Speech analysis or audio insights on their own cost nothing. Sound event detection that fails (`status: "error"` in the result) isn’t charged.

The trial includes **20 minutes** of audio in total — a one-time allowance, not a monthly one. A finished job counts its full audio length against it, whichever services ran, as long as at least one of them succeeded; a job in which every service failed isn’t counted. On the Free plan, a request whose file would take you past the remaining minutes is rejected up front with `402` ([usage limit exceeded](https://docs.cochl.ai/docs/pro/error-codes#usage-limit-exceeded)) rather than partly processed.

You can review your usage under **Usage** on the [Cochl.Sense Dashboard](https://dashboard.cochl.ai/): minutes per day and per project, and this month’s estimated charge. Before you run a file on a service page, the Dashboard also shows its length and what the run will use. On a project’s home, **Minutes this month** shows that project’s last 30 days as small bars; clicking them opens Usage filtered to the project. The [Dashboard](https://docs.cochl.ai/docs/pro/dashboard) page walks through every menu, including the **Request log** of your API calls and the **History** of your runs.

<img src="/images/dashboard-usage.png" alt="The Usage page: minutes per day stacked by project, the estimated charge this month, and minutes per project" />


<div id="file-format" style="{ scrollMarginTop: '6rem' }" />

<div id="7-additional-notes" style="{ scrollMarginTop: '6rem' }" />

## 6. Additional notes [#6-additional-notes]

### (1) Convert to supported file formats (MP3, WAV, FLAC, OGG) [#1-convert-to-supported-file-formats-mp3-wav-flac-ogg]

You usually don’t need to: the server converts most other formats for you. Convert a file yourself when the server can’t decode it, or when converting it would take longer than the 120-second limit ([decode failure](https://docs.cochl.ai/docs/pro/error-codes#audio-decode-failure)).

Pydub is an easy way to convert audio files into one of the supported formats. First, install `Pydub` by following the instructions in this [link](https://github.com/jiaaro/pydub?tab=readme-ov-file#installation). Then, write a Python script to convert your file, as shown below.

```python
from pydub import AudioSegment

audio = AudioSegment.from_file("sample.mp4", "mp4")
audio.export("sample.mp3", format="mp3")
```

For more details on `Pydub`, please refer to this [link](https://github.com/jiaaro/pydub).

<div id="5-whats-next" style="{ scrollMarginTop: '6rem' }" />

## Next steps [#next-steps]

<Cards>
  <Card title="&#x22;Sound event detection&#x22;" description="&#x22;Detection details and the result shape.&#x22;" href="/docs/pro/sound-event-detection" />

  <Card title="&#x22;Speech analysis&#x22;" description="&#x22;Transcribe speech and identify registered speakers.&#x22;" href="/docs/pro/speech-analysis" />

  <Card title="&#x22;Audio insights&#x22;" description="&#x22;A single-paragraph summary of the whole file.&#x22;" href="/docs/pro/audio-insights" />

  <Card title="&#x22;Error Codes&#x22;" description="&#x22;Every error the API and the Python library can return.&#x22;" href="/docs/pro/error-codes" />
</Cards>

**Not using Python?** Pro is a REST API over HTTPS, and the library only wraps it. [REST API](https://docs.cochl.ai/docs/pro/rest-api) shows the calls with cURL and Node.js — upload, stream or poll the result, options and limits — and your project’s home on the Dashboard shows the same request with your key filled in under **Call it from your app**.
