Skip to main content

cochl

cochl is the official Python client library for the Cochl.Sense Cloud API. Use it to detect sound events, transcribe and identify speakers, and summarize what's happening in an audio file, all from Python.

For end-user product documentation see docs.cochl.ai.

Installation

Supported on Python 3.10+.

pip install --upgrade cochl

What's in the library

The library exposes three API classes; pick the one that matches your task.

Class Use for Auth key
IntegratedApi All-in-one analysis: Sound Event Detection + Speech Analysis + Audio Insights in one request. Recommended for new integrations. Project key (X-Api-Key)
Client (also exported as EventDetectionApi) Legacy single-feature client — Sound Event Detection only, with tags[] / probability shape. Kept for v1.x compatibility. Project key (X-Api-Key)
SpeakerProfileApi Register / list / recognize / delete voice profiles used by Speech Analysis. Organization key (X-Org-Key)

Project keys are per-project (Dashboard → Projects → your project → Settings). Organization keys apply across the whole organization (Dashboard → Organization).

Project keys do not expire — rotate them by regenerating from the project's Settings tab.

Samples

Working scripts for each API class live under samples/. Replace the placeholder key and audio file path, then run with python samples/<file>.py.

samples/
├── sample_audio_insights.py        # IntegratedApi — audio_insights=True
├── sample_sound_event_detection.py # IntegratedApi — sound_event_detection=True
├── sample_speech_analysis.py       # IntegratedApi — speech_analysis=True
├── sample_speaker_profile_api.py   # SpeakerProfileApi — register / list / recognize / delete
└── legacy/
    ├── sample.py                   # Legacy Client (v1.x response shape)
    └── config.json                 # Sensitivity / result_summary / tag_filter knobs for Client

Quick start — IntegratedApi

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=True,
        audio_insights=True,
    ),
)

# Block until the job finishes, then return the final result dict.
result = api.get_completed_result(job['job_id'])
print(result)

result is a dict with one top-level key per enabled analysis, plus metadata:

  • sound_event_detection — status, and results[] on success. Each entry is a 2 s window advancing in 1 s steps (00:00–00:02, 00:01–00:03, …) carrying classes[] (each {class, confidence, id}), start_time / end_time (MM:SS.ss), start_time_sec / end_time_sec, and an id.
  • speech_analysis — status, and results[] on success: speaker-turn segments with transcript, speaker (the diarization label, SPEAKER_00, SPEAKER_01, …), speaker_name, speaker_score, start_time / end_time, start_time_sec / end_time_sec, and item_ids. speaker_name is always present: it holds the registered Speaker Profile's name when one matches, and Unknown 0, Unknown 1, … otherwise, in which case speaker_score is -1.0.
  • audio_insights — status, plus result (a single object with contains_speech, detected_language, primary_sound_environment, situation_summary, notable_events[], speech_content_summary, keywords[]) and item_ids mapping each of those fields to an item id.
  • metadata — audio.input (filename, format, size_bytes, content_type), audio.processed (sample_rate_hz, channels, encoding, resampled, downmixed), and warnings[].

Check status per service. A service that fails does not raise — the job still completes with HTTP 200, and the failure shows up as status: 'error' with an error message on that service alone:

sed = result['sound_event_detection']
if sed['status'] != 'success':
    print('SED failed:', sed['error'])
else:
    for chunk in sed['results']:
        print(chunk['start_time'], [c['class'] for c in chunk['classes']])

A single upload is capped at 1 hour of audio.

For schema details and per-feature documentation, see:

IntegratedApi accepts MP3, WAV, FLAC, OGG. Convert other formats first — see Convert to supported file formats below.

Valid service combinations

audio_insights is a summary built on top of the other two analyses, so it can't run on its own — enable it only together with both sound_event_detection and speech_analysis. At least one service must be enabled. Invalid combinations come back as 400.

sound_event_detection speech_analysis audio_insights Result
✅ ❌ ❌ OK — SED only
❌ ✅ ❌ OK — Speech Analysis only
✅ ✅ ❌ OK — SED + Speech Analysis
✅ ✅ ✅ OK — full stack (Dashboard default)
❌ ❌ ❌ 400 — no services selected
❌ ❌ ✅ 400 — audio_insights requires both SED and Speech Analysis
✅ ❌ ✅ 400 — audio_insights requires speech_analysis
❌ ✅ ✅ 400 — audio_insights requires sound_event_detection

Speaker Profiles

Register voices ahead of time so IntegratedApi's Speech Analysis can name them (instead of generic SPEAKER_00 / SPEAKER_01).

from cochl.sense import SpeakerProfileApi

api = SpeakerProfileApi('YOUR_ORGANIZATION_KEY')

# Register a profile from an audio sample.
api.add_new_voice('Anna_Kim', 'anna_sample.wav')

# List every profile registered under this organization.
print(api.list_all_speakers())

# Match speakers in a separate file (uses the registered profiles).
print(api.recognize('meeting.wav'))

# Delete a profile.
api.remove('Anna_Kim')

Notes:

  • Each add_new_voice / recognize upload is capped at 10 MB per file.
  • SpeakerProfileApi uses the organization key (X-Org-Key), not a project key.

See Custom Sound: Speaker Profile for the full registration flow.

Other notes

Convert to supported file formats

Pydub is one easy way to convert audio into a supported format. Install it per the Pydub installation guide, then:

from pydub import AudioSegment

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

For more on Pydub, see the Pydub repo.

Repo layout

This package is published to PyPI from a private development repository (cochl-sense-py-private) and mirrored to the public cochlearai/cochl-sense-py repo for end-user access. Issues and pull requests should be filed against the public mirror.

Links

Release files for cochl 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cochl 2.0.1
File Size Uploaded
cochl-2.0.1.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cochl 2.0.1
File Interpreter ABI Platform
cochl-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.9 kB

Release files / cochl-2.0.1.tar.gz

Download URL cochl-2.0.1.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
49cfc2c81ea55f1308fa03d2cdd636ad68d72b0a5072817fc86a2c03da0ee50a
BLAKE2b-256 checksum
How to use checksums
de4954d634f0751c7e442974d116c91ef324f6dfa36485709c54da955f0424c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / cochl-2.0.1-py3-none-any.whl

Download URL cochl-2.0.1-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
596943917ddf630daa81dee28741fac1abe65e2a8665041a6f4a1be357fbf2b3
BLAKE2b-256 checksum
How to use checksums
e65dc25fac6f091c0130a9a074e14c78b59d7d4872943713790e9cfb397802a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

0.2.11

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page