Skip to main content

LASER ASD - Lip Landmark Assisted Speaker Detection (PyPI Package)

PyPI version Python 3.8+ License: MIT

Note: This is a PyPI packaging wrapper for easy installation.

Original Repository: https://github.com/plnguyen2908/LASER_ASD

All credit for the LASER ASD model architecture and training goes to the original authors.

This package provides a simple Python API for the LASER ASD (Lip Landmark Assisted Speaker Detection) model, enabling easy installation via pip and straightforward inference.

Original Work

This package is based on the LASER ASD implementation by Phat Lam Nguyen et al.:

If you use this code, please cite the original work (see Citation section).

Features

  • Active Speaker Detection using audio-visual fusion
  • Based on LoCoNet architecture with LASER landmark injection
  • Simple Python API for inference
  • GPU acceleration with CUDA support
  • Compatible with PyTorch 1.10+

Installation

pip install laser-asd

Quick Start

import numpy as np
from laser_asd import LaserASDModel

# Initialize model
model = LaserASDModel(device="cuda")

# Load pre-trained weights (download from original repo)
model.load_weights("/path/to/loconet_laser.model")

# Prepare inputs
# face_crops: numpy array of shape [T, H, W, C] or [T, H, W]
# audio_data: numpy array of shape [samples] at 16kHz
face_crops = np.random.rand(100, 112, 112, 3).astype(np.float32)
audio_data = np.random.rand(64000).astype(np.float32)  # 4 seconds at 16kHz

# Predict speaking scores
scores = model.predict(face_crops, audio_data, sample_rate=16000, fps=25.0)

# scores >= 0 indicates speaking
is_speaking = scores >= 0

Model Weights

Pre-trained model weights must be downloaded from the original repository:

Set the model path via environment variable:

export LASER_ASD_MODEL_PATH=/path/to/loconet_laser.model

Or pass it directly:

model = LaserASDModel(device="cuda", model_path="/path/to/loconet_laser.model")

API Reference

LaserASDModel

class LaserASDModel:
    def __init__(
        self,
        device: str = "cuda",
        model_path: Optional[Path] = None,
        use_landmarks: bool = False,
    ):
        """
        Initialize LASER ASD model.

        Args:
            device: Device to run model on ('cuda' or 'cpu')
            model_path: Path to model weights file
            use_landmarks: Whether to use landmark features (False uses zeros)
        """

    def load_weights(self, model_path: Optional[str] = None):
        """Load model weights."""

    def predict(
        self,
        face_crops: np.ndarray,
        audio_data: np.ndarray,
        sample_rate: int = 16000,
        fps: float = 25.0,
    ) -> np.ndarray:
        """
        Predict speaking probability for each frame.

        Args:
            face_crops: Face crop images [T, H, W, C] or [T, H, W]
            audio_data: Audio waveform [samples]
            sample_rate: Audio sample rate (default: 16000)
            fps: Video frame rate (default: 25.0)

        Returns:
            Per-frame speaking scores [T] (>= 0 means speaking)
        """

Factory Function

def create_laser_model(
    device: str = "cuda",
    model_path: Optional[str] = None,
    **kwargs,
) -> LaserASDModel:
    """Factory function to create LASER ASD model."""

Requirements

  • Python >= 3.8
  • PyTorch >= 1.10.0
  • torchvision >= 0.11.0
  • numpy >= 1.20.0
  • opencv-python >= 4.5.0
  • resampy >= 0.4.0
  • python_speech_features >= 0.6

Citation

If you use this code, please cite the original LASER ASD paper:

@inproceedings{nguyen2024laser,
  title={LASER: Lip Landmark Assisted Speaker Detection},
  author={Nguyen, Phat Lam and others},
  booktitle={Proceedings},
  year={2024}
}

License

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

The original LASER ASD code is also MIT licensed.

Acknowledgments

Differences from Original Repository

This PyPI package adds:

  • wrapper.py: Simple inference API (LaserASDModel class)
  • pyproject.toml: PyPI packaging configuration
  • Modified imports for package compatibility

The core model architecture and weights are unchanged from the original.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

For issues related to the model architecture, please refer to the original repository.

Metadata

Release files for laser-asd 0.1.1

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

Source distribution (sdist)

Source distribution for laser-asd 0.1.1
File Size Uploaded
laser_asd-0.1.1.tar.gz 50.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for laser-asd 0.1.1
File Interpreter ABI Platform
laser_asd-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 112.5 kB

Release files / laser_asd-0.1.1.tar.gz

Download URL laser_asd-0.1.1.tar.gz
Size 50.5 kB
Tags Source
SHA-256 checksum
How to use checksums
534e786338288b9740daaae280d826f769fc3792dfc3d09e9ddea7481867d5cd
BLAKE2b-256 checksum
How to use checksums
de5c28282a6b02a70fd25a0cde253e3133fc615b33edb50453548a841289b39b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / laser_asd-0.1.1-py3-none-any.whl

Download URL laser_asd-0.1.1-py3-none-any.whl
Size 62.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bf589132cfa31f13fca8659cd2b0dc2f1e531b015304496d5079cac02643d8c
BLAKE2b-256 checksum
How to use checksums
08be62a429e04442c77f0636d435dd3b86f8c3a2ffa1bfdad2863d7cd3a9cf56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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