Skip to main content

IISY ASR Pipeline

An automated speech recognition (ASR) pipeline with speech enhancement, transcription, and speaker identification capabilities.

Overview

The IISY ASR Pipeline is a comprehensive solution for processing audio input in real-time. It combines multiple processing stages:

  1. Speech Enhancement - Using DeepFilterNet to improve audio quality
  2. Speech Transcription - Converting speech to text with Faster Whisper
  3. Speaker Identification - Identifying speakers using SpeechBrain models

Installation

Requirements

  • Python 3.11.10
  • CUDA-compatible GPU (recommended for optimal performance)

Installation

You can install the package directly from PyPI:

# For CPU-only installation
pip install iisy-asr-pipeline

# For GPU support (CUDA)
pip install iisy-asr-pipeline[cuda]

For GPU support, you'll need to manually install the CUDA-compatible version of PyTorch first:

# Install CUDA-compatible PyTorch (example for CUDA 11.8)
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118

# Then install the package with CUDA support
pip install iisy-asr-pipeline[cuda]

You can adjust the CUDA version (cu117, cu118, cu121, etc.) based on your system's requirements.

Usage

Listing Available Audio Devices

Before running the pipeline, you may want to identify the correct audio input device:

python -m iisy.run_pipeline --list-devices

Basic Usage

Run the ASR pipeline with default settings:

python -m iisy.run_pipeline --input-device-index 1

Command Line Options

The pipeline can be customized with various command line arguments:

python -m iisy.run_pipeline [OPTIONS]

Device Settings

  • --device - Device to run models on (cuda or cpu, default: cuda if available, otherwise cpu)
  • --input-device-index - Input audio device index (default: 1)
  • --list-devices - List all available audio devices and exit

Audio Parameters

  • --chunk-size - Number of audio frames per buffer (default: 2048)
  • --channels - Number of audio channels (1=mono, 2=stereo, default: 1)
  • --buffer-size - Size of the audio buffer (default: 1000)

Model Parameters

  • --whisper-model - Whisper model size (tiny, base, small, medium, large, turbo, default: medium)
  • --speaker-model - Speaker identification model path (default: speechbrain/spkrec-resnet-voxceleb)

Silence Detection Parameters

  • --silence-threshold - Energy threshold for silence detection (default: 0.01)
  • --min-silence-duration - Minimum duration of silence for sentence boundary in seconds (default: 2.0)

Other Parameters

  • --speaker-threshold - Threshold for speaker identification (default: 0.55)
  • --verbose - Enable verbose logging

Example Commands

Run with a larger Whisper model for better transcription accuracy:

python -m iisy.run_pipeline --whisper-model large

Use a different microphone (device index 2) and enable verbose logging:

python -m iisy.run_pipeline --input-device-index 2 --verbose

Use ECAPA-TDNN model for speaker identification:

python -m iisy.run_pipeline --speaker-model speechbrain/spkrec-ecapa-voxceleb

Advanced Usage

Programmatic Integration

You can integrate the ASR pipeline into your own Python applications:

import threading
import pyaudio
import torch
from iisy.context_window import ContextWindow
from iisy.pipeline.asr_pipeline import AsrPipeline

# Initialize audio capture
p = pyaudio.PyAudio()
in_stream = p.open(
    format=pyaudio.paInt16,
    channels=1,
    rate=16000,
    input=True,
    input_device_index=1,
    frames_per_buffer=2048
)

# Create audio buffer
audio_buffer = ContextWindow(1000)

# Configure pipeline
pipeline_config = {
    'speaker': {
        'model': "speechbrain/spkrec-resnet-voxceleb",
        'savedir': "spkrec-resnet-voxceleb",
        'speaker_threshold': 0.55
    },
    'whisper': {
        "model_size": "medium",
        "device_index": 0,
        "compute_type": "float16"
    }
}

# Create pipeline
pipeline = AsrPipeline(
    input_sr=16000,
    device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
    min_silence_duration=2.0,
    verbose=True,
    **pipeline_config
)

# Set up audio capture
def audio_capture():
    while True:
        try:
            audio_data = in_stream.read(2048, exception_on_overflow=False)
            audio_buffer.add(audio_data)
        except Exception as e:
            print(f"Audio capture error: {e}")
            break

# Start capture thread
capture_thread = threading.Thread(target=audio_capture, daemon=True)
capture_thread.start()

# Run pipeline
try:
    pipeline.run(audio_buffer)
finally:
    in_stream.stop_stream()
    in_stream.close()
    p.terminate()

Custom Processing Steps

You can customize each processing step of the pipeline:

from iisy.pipeline.speech_enhancement_step import SpeechEnhancementStep
from iisy.pipeline.speech_transcription_step import SpeechTranscriptionStep
from iisy.pipeline.speaker_identification_step import SpeakerIdentificationStep

# Create custom steps
enhancement_step = SpeechEnhancementStep(...)
transcription_step = SpeechTranscriptionStep(...)
identification_step = SpeakerIdentificationStep(...)

# Create pipeline with custom steps
pipeline = AsrPipeline(
    enhancement_step=enhancement_step,
    transcription_step=transcription_step,
    identification_step=identification_step
)

Troubleshooting

Common Issues

  1. Audio device not found: Verify your input device with --list-devices and select the correct index.

  2. CUDA out of memory: Try using a smaller Whisper model (--whisper-model small or --whisper-model base).

  3. Poor transcription quality: Consider the following:

    • Try a larger Whisper model
    • Ensure your microphone is positioned correctly
    • Adjust --min-silence-duration for better sentence boundaries
  4. Speaker identification issues: Try adjusting the --speaker-threshold value. Higher values require more confidence for speaker identification.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

This project utilizes several open-source libraries:

Authors

Metadata

Release files for iisy-asr-pipeline 1.0.1.post2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iisy-asr-pipeline 1.0.1.post2
File Size Uploaded Provenance Actions
iisy_asr_pipeline-1.0.1.post2.tar.gz 16.1 kB Without provenance Details for iisy_asr_pipeline-1.0.1.post2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for iisy-asr-pipeline 1.0.1.post2
File Interpreter ABI Platform Actions
iisy_asr_pipeline-1.0.1.post2-py3-none-any.whl Python 3 none any Details for iisy_asr_pipeline-1.0.1.post2-py3-none-any.whl

Total release size: 33.0 kB

Release files / iisy_asr_pipeline-1.0.1.post2.tar.gz

Download URL iisy_asr_pipeline-1.0.1.post2.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6f7f97a3a9c81091ca2b72f7ef726cf279a5edeefe395ef505c4bb86e1bc7b58
BLAKE2b-256 checksum
How to use checksums
bb10a8ce9a3509832526960e605ca350a48361d17d750a30b970d853b6d16989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.13

Release files / iisy_asr_pipeline-1.0.1.post2-py3-none-any.whl

Download URL iisy_asr_pipeline-1.0.1.post2-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99c0749d6d55963314bdcb833056899bfd8151bdc5bc3d60983050001105151f
BLAKE2b-256 checksum
How to use checksums
a0b97a4bc783c5224afb97b2dbeab7863a96e5d9e7a75271c391ff27f5ef4398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.13

Security for iisy-asr-pipeline 1.0.1.post2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page