Skip to main content

Code Samples & Integration Guides

Ready-to-use code examples for Python, Node.js, Bash, and popular integrations

Quick Start

Classify audio in just a few lines of code

# Quick Start: Classify audio in 3 lines import requests response = requests.post( "https://api.h-ear.world/api/v1/classify", headers={"X-NCM-Api-Key": "ncm_YOUR_KEY"}, json={"url": "https://example.com/audio.mp3"} ) print(response.json())

Full Examples

Complete, production-ready code samples

#!/usr/bin/env python3 """ H‑ear.World API - Python Example Classify audio from URL or local file """ import requests import base64 import sys API_KEY = "ncm_YOUR_API_KEY" API_URL = "https://api.h-ear.world/api/v1" def classify_from_url(audio_url: str) -> dict: """Classify audio from a public URL""" response = requests.post( f"{API_URL}/classify", headers={ "X-NCM-Api-Key": API_KEY, "Content-Type": "application/json" }, json={ "url": audio_url, "threshold": 0.3 # Optional: confidence threshold }, timeout=300 # 5 min timeout for processing ) response.raise_for_status() return response.json() def classify_from_file(file_path: str) -> dict: """Classify audio from local file (base64 encoded)""" with open(file_path, "rb") as f: audio_base64 = base64.b64encode(f.read()).decode("utf-8") response = requests.post( f"{API_URL}/classify", headers={ "X-NCM-Api-Key": API_KEY, "Content-Type": "application/json" }, json={ "base64": audio_base64, "fileName": file_path.split("/")[-1] }, timeout=300 ) response.raise_for_status() return response.json() if __name__ == "__main__": # Example usage result = classify_from_url("https://example.com/dog-barking.mp3") print(f"Request ID: {result['requestId']}") print(f"Duration: {result['duration']}s") print(f"Events found: {result['eventCount']}") print("\nClassifications:") for c in result.get("classifications", []): print(f" - {c['class']}: {c['confidence']:.1%}") print(f"\nStatus: {result.get('status', 'N/A')}")

Integration Guides

Connect H‑ear.World to your smart home, edge devices, and automation workflows

Home Assistant

Automate noise detection with your existing smart home cameras

Raspberry Pi

Build a continuous noise monitor with edge recording

Batch Import

Process multiple files from SD cards, NAS, or cloud storage

# Home Assistant Configuration # Add to configuration.yaml rest_command: ncm_classify: url: "https://api.h-ear.world/api/v1/classify" method: POST headers: X-NCM-Api-Key: !secret ncm_api_key Content-Type: "application/json" payload: '{"url": "{{ url }}", "fileName": "{{ filename }}"}' timeout: 300 # Add to secrets.yaml # ncm_api_key: ncm_YOUR_API_KEY # Example automation automation: - alias: "NCM Noise Detection" trigger: - platform: state entity_id: binary_sensor.tapo_noise to: "on" action: # Record 5 minutes of audio - service: camera.record target: entity_id: camera.tapo_c310 data: filename: "/config/recordings/{{ now().strftime('%Y%m%d-%H%M%S') }}.mp4" duration: 300 # Wait for recording + buffer - delay: "00:05:30" # Upload to your Azure Blob storage first, then call NCM # (Azure Blob integration required) - service: rest_command.ncm_classify data: url: "https://yourstorage.blob.core.windows.net/recordings/..." filename: "noise-{{ now().strftime('%Y%m%d-%H%M%S') }}.mp4"

Camera Export Guides

Step-by-step instructions for exporting recordings from popular security cameras

  • 1. Open Ring app and tap the event you want to export
  • 2. Tap the Share icon (bottom right)
  • 3. Select "Save Video" to save to your device
  • 4. File saves as .ogg format
  • 5. Upload directly to H‑ear.World (OGG/Opus is natively supported)

  • 1. Open Tapo app and select your camera
  • 2. Tap Playback to view recordings
  • 3. Select the date/time range you want
  • 4. Tap the Download icon to save MP4
  • 5. Upload the MP4 file to H‑ear.World

  • 1. Open Google Home app
  • 2. Select your Nest camera
  • 3. View the event you want to export
  • 4. Tap Download to save as MP4
  • 5. Upload to H‑ear.World

  • 1. Open the respective camera app
  • 2. Navigate to recordings/events
  • 3. Select the clip to download
  • 4. Save to device as MP4
  • 5. Upload to H‑ear.World
Supported Camera Formats

H‑ear.World supports all major security camera export formats:

BrandExport FormatStatus
Ring, Nest, Arlo, Eufy, Blink, SimpliSafe, Reolink, SwannMP4 (AAC audio)
Supported
Wyze, TP-Link TapoMP4 (G.711 audio)
Supported
Hikvision, Dahua, UniFi, LorexMP4 export
Supported
Ring (audio only)OGG/Opus
Native Support
Explore All Integrations

See the full range of integration options including ESP32, old smartphones, and more device guides.

Need Help?

Check out our resources or contact support: