Skip to content

Latest commit

 

History

History
78 lines (51 loc) · 2.5 KB

File metadata and controls

78 lines (51 loc) · 2.5 KB

API reference

Public surface of revoice. Import the top-level names directly from the package; the submodules hold the finer-grained helpers.

Top level

from revoice import (
    denoise, dereverb, declip, conceal,
    evaluate, Pipeline, build_pipeline,
    stft, istft, StftConfig, __version__,
)

denoise(signal, *, method="wiener", config=None, noise_percentile=10.0, oversubtraction=1.5, floor=0.02)

Denoise a noisy speech signal by short-time spectral attenuation. method is "wiener" or "spectral_subtraction". Returns a signal the same length as the input.

dereverb(signal, *, decay=0.4, delay=3, floor=0.05, config=None)

Suppress late reverberation. decay in (0, 1) sets tail strength, delay is the onset of the late tail in frames.

declip(signal, *, threshold=None)

Reconstruct clipped regions by cubic interpolation. threshold is auto-detected from the peak when omitted.

conceal(signal, lost, *, sample_rate=16000, min_pitch_hz=70.0, max_pitch_hz=400.0, fade=32)

Fill lost samples (marked by the boolean lost mask) using waveform-similarity extrapolation.

evaluate(reference, degraded, *, sample_rate=16000, config=None) -> dict

Compute all metrics at once: snr, segmental_snr, lsd, stoi, pesq.

Pipeline / build_pipeline(names)

Compose restoration stages. Pipeline().add(fn) appends any Signal -> Signal callable; add_named("denoise") wires a built-in. build_pipeline(["declip", "denoise"]) is a shortcut.

stft(signal, config=None) / istft(spectrum, length, config=None)

Forward and inverse STFT. StftConfig(n_fft=512, hop=128, window="hann") carries the parameters.

revoice.metrics

snr, segmental_snr, log_spectral_distance, stoi, pesq, evaluate. Higher is better everywhere except log_spectral_distance (lower is better).

revoice.simulate

add_noise(signal, snr_db, *, rng=None, color="white"), add_reverb(signal, *, rt60=0.4, sample_rate=16000, rng=None), clip(signal, threshold), drop_packets(signal, *, packet_ms=20.0, loss_rate=0.1, sample_rate=16000, rng=None) returning (corrupted, lost_mask).

revoice.io

read_wav(path) -> (signal, sample_rate) and write_wav(path, signal, sample_rate).

revoice.windows

get_window(name, length), hann, hamming, cosine, sqrt_hann, and check_cola(window, hop, *, tol=1e-6).

revoice.backend

torch_available(), resolve_backend(name), and the FFT entry points rfft / irfft that dispatch to NumPy or PyTorch.