LogoLogo
AI HubCommunityWebsite
  • Start Here
  • AI Hub
    • Overview
    • Quickstart
    • Teams
    • Device Farm
    • Browser Inference
    • Model Zoo
      • Hailo
      • Intel
      • MemryX
      • BrainChip
      • Google
      • DeGirum
      • Rockchip
    • View and Create Model Zoos
    • Compiler
    • PySDK Integration
  • PySDK
    • Overview
    • Quickstart
    • Installation
    • Runtimes and Drivers
      • Hailo
      • OpenVINO
      • MemryX
      • BrainChip
      • Rockchip
      • ONNX
    • PySDK User Guide
      • Core Concepts
      • Organizing Models
      • Setting Up an AI Server
      • Loading an AI Model
      • Running AI Model Inference
      • Model JSON Structure
      • Command Line Interface
      • API Reference Guide
        • PySDK Package
        • Model Module
        • Zoo Manager Module
        • Postprocessor Module
        • AI Server Module
        • Miscellaneous Modules
      • Older PySDK User Guides
        • PySDK 0.16.1
        • PySDK 0.16.0
        • PySDK 0.15.2
        • PySDK 0.15.1
        • PySDK 0.15.0
        • PySDK 0.14.3
        • PySDK 0.14.2
        • PySDK 0.14.1
        • PySDK 0.14.0
        • PySDK 0.13.4
        • PySDK 0.13.3
        • PySDK 0.13.2
        • PySDK 0.13.1
        • PySDK 0.13.0
    • Release Notes
      • Retired Versions
    • EULA
  • DeGirum Tools
    • Overview
      • Streams
        • Streams Base
        • Streams Gizmos
      • Compound Models
      • Analyzers
        • Clip Saver
        • Event Detector
        • Line Count
        • Notifier
        • Object Selector
        • Object Tracker
        • Zone Count
      • Inference Support
      • Support Modules
        • Audio Support
        • Model Evaluation Support
        • Math Support
        • Object Storage Support
        • UI Support
        • Video Support
  • DeGirumJS
    • Overview
    • Get Started
    • Understanding Results
    • Release Notes
    • API Reference Guides
      • DeGirumJS 0.1.3
      • DeGirumJS 0.1.2
      • DeGirumJS 0.1.1
      • DeGirumJS 0.1.0
      • DeGirumJS 0.0.9
      • DeGirumJS 0.0.8
      • DeGirumJS 0.0.7
      • DeGirumJS 0.0.6
      • DeGirumJS 0.0.5
      • DeGirumJS 0.0.4
      • DeGirumJS 0.0.3
      • DeGirumJS 0.0.2
      • DeGirumJS 0.0.1
  • Orca
    • Overview
    • Benchmarks
    • Unboxing and Installation
    • M.2 Setup
    • USB Setup
    • Thermal Management
    • Tools
  • Resources
    • External Links
Powered by GitBook

Get Started

  • AI Hub Quickstart
  • PySDK Quickstart
  • PySDK in Colab

Resources

  • AI Hub
  • Community
  • DeGirum Website

Social

  • LinkedIn
  • YouTube

Legal

  • PySDK EULA
  • Terms of Service
  • Privacy Policy

© 2025 DeGirum Corp.

On this page
  • Audio Support Module Overview
  • Functions
  • open_audio_stream(sampling_rate_hz, ...)
  • audio_source(stream, ...)
  • audio_overlapped_source(stream, ...)

Was this helpful?

  1. DeGirum Tools
  2. Overview
  3. Support Modules

Audio Support

This API Reference is based on DeGirum Tools version 0.16.7.

Audio Support Module Overview

This module provides utilities for opening microphone or file-based audio streams and for generating audio frames. The module provides context managers and generators that simplify audio capture and processing workflows.

Key Features

  • Audio Stream Management: Open and manage audio streams from microphones and files

  • Buffer Generation: Generate audio frames with configurable buffer sizes

  • Overlapping Buffers: Support for overlapping audio buffers

  • Format Support: Handle WAV files and microphone input

  • Stream Control: Non-blocking and blocking stream operations

  • Error Handling: Robust error handling for stream operations

Typical Usage

  1. Call open_audio_stream() to create an audio stream

  2. Iterate over audio_source() or audio_overlapped_source() to process frames

  3. Use non-blocking mode for real-time processing

  4. Handle stream errors and cleanup

Integration Notes

  • Works with PyAudio for microphone input

  • Supports WAV file format

  • Handles both local and remote audio sources

  • Provides consistent interface across platforms

Key Functions

  • open_audio_stream(): Context manager for microphone or WAV files

  • audio_source(): Generator yielding audio buffers

  • audio_overlapped_source(): Generator yielding overlapping buffers

Configuration Options

  • Sampling rate

  • Buffer size

  • Source selection

  • Blocking mode

Functions

open_audio_stream(sampling_rate_hz, ...)

open_audio_stream(sampling_rate_hz, buffer_size, audio_source=None)

Open an audio stream.

This context manager opens a microphone or WAV file as an audio stream and automatically closes it when the context exits.

Parameters:

Name
Type
Description
Default

sampling_rate_hz

int

Desired sample rate in hertz.

required

buffer_size

int

Buffer size in frames.

required

audio_source

Union[int, str, None]

Source identifier. Use an integer for a microphone index, a string for a WAV file path or URL, or None to use the default source.

None

Yields:

Type
Description

Any

Stream-like object with get() method returning audio buffers.

Raises:

Type
Description

Exception

If the audio stream cannot be opened or the WAV file format is invalid.

audio_source(stream, ...)

audio_source(stream, check_abort, non_blocking=False)

Yield audio frames from a stream.

Parameters:

Name
Type
Description
Default

stream

Any

Audio stream object returned by open_audio_stream().

required

check_abort

Callable[[], bool]

Callback that returns True to stop iteration.

required

non_blocking

bool

If True and no frame is available, None is yielded instead of blocking. Defaults to False.

False

Yields:

Type
Description

Optional[ndarray]

Waveform of int16 samples or None when no data is available and non_blocking is True.

audio_overlapped_source(stream, ...)

audio_overlapped_source(stream, check_abort, non_blocking=False)

Generate audio frames with 50% overlap.

The function reads blocks from stream and yields frames that overlap by half of their length. Overlapping frames produce smoother results for audio analysis.

Parameters:

Name
Type
Description
Default

stream

Any

Audio stream object returned by open_audio_stream().

required

check_abort

Callable[[], bool]

Callback that returns True to stop iteration.

required

non_blocking

bool

If True and no frame is available, None is yielded instead of blocking. Defaults to False.

False

Yields:

Type
Description

Optional[ndarray]

Waveform of int16 samples with 50% overlap, or None when no data is available and non_blocking is True.

PreviousSupport ModulesNextModel Evaluation Support

Last updated 2 days ago

Was this helpful?