Socket
Book a DemoInstallSign in
Socket

pyrnnoise

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyrnnoise

PyRnNoise

0.3.8
pipPyPI
Maintainers
1

pyrnnoise

PyPI License

Python bindings for RNNoise, a recurrent neural network for audio noise reduction.

Features

  • Real-time noise suppression for speech audio
  • Command-line interface for processing audio files
  • Supports mono and stereo audio files
  • Visualize voice activity detection probabilities

Installation

pip install pyrnnoise

Usage

Command-line interface

# Basic usage
denoise input.wav output.wav

# With voice activity detection plot
denoise input.wav output.wav --plot

Python API

from pyrnnoise import RNNoise

# Create denoiser instance
denoiser = RNNoise(sample_rate=48000)

# Process audio file
for speech_prob in denoiser.denoise_wav("input.wav", "output.wav"):
    print(f"Processing frame with speech probability: {speech_prob}")

Advanced Usage

The RNNoise class provides several methods for processing audio at different levels:

  • denoise_frame(frame, partial=False): Process a single audio frame (480 samples at 48kHz)

    • Returns a tuple of (speech_probabilities, denoised_frame)
    • speech_probabilities: Voice activity detection probabilities for each channel
    • denoised_frame: The denoised audio frame
  • denoise_chunk(chunk, partial=False): Process a chunk of audio data

    • Takes a numpy array of audio samples [num_channels, num_samples]
    • Yields tuples of (speech_probabilities, denoised_frame) for each frame
    • Useful for processing audio streams or large audio files in chunks

Example using denoise_chunk:

import numpy as np
from pyrnnoise import RNNoise

# Create denoiser instance
denoiser = RNNoise(sample_rate=48000)

# Generate or load some audio data (stereo in this example)
audio_data = np.random.randint(-32768, 32767, (2, 48000), dtype=np.int16)

# Process audio chunk
for speech_prob, denoised_audio in denoiser.denoise_chunk(audio_data):
    print(f"Speech probability: {speech_prob}")
    # Process denoised_audio as needed

Build from source

# Clone with submodules
git submodule update --init

# Build RNNoise library
cmake -B pyrnnoise/build -DCMAKE_BUILD_TYPE=Release
cmake --build pyrnnoise/build --target install

# Install Python package in development mode
pip install -e .

License

Apache License 2.0

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.