Skip to main content

Easy Audio Interfaces is a Python library that provides a simple and flexible way to work with audio streams, including recording, playback, network transfer, and processing.

Project description

Easy Audio Interfaces

Easy Audio Interfaces is a Python library that provides a simple and flexible way to work with audio streams, including recording, playback, network transfer, and processing.

Features

  • Socket-based audio streaming
  • Local file reading and writing
  • Audio resampling and rechunking
  • Voice activity detection (VAD) using Silero VAD model
  • Network file transfer

Quick Start

Here's a simple example to get you started - record audio from a socket, process it, and save to a file:

from easy_audio_interfaces import SocketReceiver, LocalFileSink, RechunkingBlock, ResamplingBlock

async with SocketReceiver() as receiver, LocalFileSink("output.wav") as sink:
    rechunker = RechunkingBlock(chunk_size=512)
    resampler = ResamplingBlock(original_sample_rate=receiver.sample_rate, resample_rate=16000)

    rechunked_stream = rechunker.rechunk(receiver)
    resampled_stream = resampler.resample(rechunked_stream)
    await sink.write_from(resampled_stream)

Installation

From PyPI

uv add easy-audio-interfaces

From Source

uv add "https://github.com/AnkushMalaker/python-audio-interfaces.git"

Optional Dependencies

Based on the functionality you require, you should consider installing with the following extras:

# For speech-to-text
uv add "easy-audio-interfaces[stt]"

# For voice activity detection
uv add "easy-audio-interfaces[silero-vad]"

# For Bluetooth audio
uv add "easy-audio-interfaces[bluetooth]"

# For local audio devices
uv add "easy-audio-interfaces[local-audio]"

Usage

Main Components

Audio Sources

  • SocketReceiver: Receives audio data over a WebSocket connection
  • LocalFileStreamer: Streams audio data from a local file

Audio Sinks

  • SocketStreamer: Sends audio data over a WebSocket connection
  • LocalFileSink: Writes audio data to a local file

Processing Blocks

  • CollectorBlock: Collects audio samples for a specified duration
  • ResamplingBlock: Resamples audio to a different sample rate
  • RechunkingBlock: Rechunks audio data into fixed-size chunks

Voice Activity Detection

  • SileroVad: Uses the Silero VAD model for voice activity detection
  • VoiceGate: Applies voice activity detection to segment audio

Examples

Basic Friend Recorder

Records voice segments from a network stream using VAD:

python -m easy_audio_interfaces.examples.basic_friend_recorder

File Network Transfer

Transfer audio files over a network:

# Sender
python -m easy_audio_interfaces.examples.file_network_transfer sender input_file.wav --host localhost --port 8080

# Receiver
python -m easy_audio_interfaces.examples.file_network_transfer receiver output_file.wav --host 0.0.0.0 --port 8080

For more detailed usage and API documentation, please refer to the docstrings in the source code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easy_audio_interfaces-0.4.1.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easy_audio_interfaces-0.4.1-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

Details for the file easy_audio_interfaces-0.4.1.tar.gz.

File metadata

File hashes

Hashes for easy_audio_interfaces-0.4.1.tar.gz
Algorithm Hash digest
SHA256 1128f75701486dda67499869321ee3727fb814da82e468a43a8a094f66626b6d
MD5 b7d065da9d9559ded09cf8c4feb6e7d9
BLAKE2b-256 2578c47046fc2f12a1a55f624ad3dc4db3c8ac1a4a948fc1274a46f18e4acac9

See more details on using hashes here.

File details

Details for the file easy_audio_interfaces-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for easy_audio_interfaces-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6502a3d0e8289d6e33c6f030809758f5e0f5a02157f0a657041c4ff7a4b68de4
MD5 7f8d690845d9675ac3d6e6d55f884c6c
BLAKE2b-256 6eabefeae9fabe733251857f1c418a8a0597b5a32f7840f62e23e7525975db0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page