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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easy_audio_interfaces-0.2.7.tar.gz.
File metadata
- Download URL: easy_audio_interfaces-0.2.7.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74be9a703ca5009f489e112d75fe2981bb921cc6f1302e2b96e545008bad5fb8
|
|
| MD5 |
0c766cf3539e7fbefe4f46d1f7f241cb
|
|
| BLAKE2b-256 |
388ae16d55d63542a43c5d240baeeb5632c83137e3052737841d13e17a13ca38
|
File details
Details for the file easy_audio_interfaces-0.2.7-py3-none-any.whl.
File metadata
- Download URL: easy_audio_interfaces-0.2.7-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76d24f51455e0ee4dd49cd52bfbfe1984e72c31b0ccf221337d79c368665ffe1
|
|
| MD5 |
1a093f1048521dd7a6a5bb6cb059cc4b
|
|
| BLAKE2b-256 |
bbf474bbacbbc072f4686efccad937633f13213c86a4a96d21f9a1bce9df3a07
|