Go Two-Tone Detector

This project is a Go application for detecting two-tone sequences (such as paging tones) in real-time audio streams. It connects to an RTSP stream, decodes G711 mu-law audio, and analyzes the audio for specific tone patterns using the Goertzel algorithm. When a valid two-tone sequence is detected, the app can record and save the relevant audio segment as a WAV file.

Features

  • RTSP Client: Connects to audio streams using RTSP protocol.
  • G711 mu-law Decoding: Converts mu-law encoded audio to PCM samples.
  • Two-Tone Detection: Uses Goertzel algorithm to detect and confirm tone sequences.
  • Recording: Automatically records and saves audio segments containing detected tones.
  • Configurable Parameters: Window size, hop size, thresholds, and durations are adjustable via command-line flags.
  • Graceful Shutdown: Handles interrupts and ensures recordings are saved before exit.

Usage

go run main.go -rtsp <RTSP_URL> [flags]

Example Flags

  • -rtsp : RTSP stream URL (required)
  • -winMs : Window size in milliseconds (default: 100)
  • -hopMs : Hop size in milliseconds (default: 50)
  • -ratioThresh : Power ratio threshold for tone detection
  • -rmsThresh : RMS threshold for signal detection
  • -minAms : Minimum duration for Tone A (ms)
  • -minBms : Minimum duration for Tone B (ms)
  • -gapMaxMs : Maximum allowed gap between tones (ms)
  • -silenceThresh : RMS threshold for silence detection
  • -silenceDurMs : Duration of silence before stopping recording (ms)

Output

  • Detected tone events are logged to the console.
  • Audio segments containing detected tones are saved as WAV files in the current directory.

Requirements

Description
No description provided
Readme 43 KiB
Languages
Go 95.2%
Dockerfile 4.8%