Skip to main content

panns_inference: audio tagging and sound event detection inference toolbox

Project description

PANNs inferece

panns_inference provides an easy to use Python interface for audio tagging and sound event detection. The audio tagging and sound event detection models are trained from PANNs: Large-Scale Pretrained Audio Neural Networks for Audio Pattern Recognition: https://github.com/qiuqiangkong/audioset_tagging_cnn

Installation

PyTorch>=1.0 is required.

$ pip install panns-inference

Usage

$ python3 example.py

For example:

import librosa
import panns_inference
from panns_inference import AudioTagging, SoundEventDetection, labels

audio_path = 'examples/R9_ZSCveAHg_7s.wav'
(audio, _) = librosa.core.load(audio_path, sr=32000, mono=True)
audio = audio[None, :]  # (batch_size, segment_samples)

print('------ Audio tagging ------')
at = AudioTagging(checkpoint_path=None, device='cuda')
(clipwise_output, embedding) = at.inference(audio)

print('------ Sound event detection ------')
sed = SoundEventDetection(checkpoint_path=None, device='cuda')
framewise_output = sed.inference(audio)

Results

------ Audio tagging ------
Checkpoint path: /root/panns_data/Cnn14_mAP=0.431.pth
GPU number: 1
Speech: 0.893
Telephone bell ringing: 0.754
Inside, small room: 0.235
Telephone: 0.183
Music: 0.092
Ringtone: 0.047
Inside, large room or hall: 0.028
Alarm: 0.014
Animal: 0.009
Vehicle: 0.008
------ Sound event detection ------
Checkpoint path: /root/panns_data/Cnn14_mAP=0.431.pth
GPU number: 1
Save fig to results/sed_result.pdf

Sound event detection plot:

Cite

[1] Kong, Qiuqiang, Yin Cao, Turab Iqbal, Yuxuan Wang, Wenwu Wang, and Mark D. Plumbley. "PANNs: Large-Scale Pretrained Audio Neural Networks for Audio Pattern Recognition." arXiv preprint arXiv:1912.10211 (2019).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panns-inference-0.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

panns_inference-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file panns-inference-0.1.1.tar.gz.

File metadata

  • Download URL: panns-inference-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.5

File hashes

Hashes for panns-inference-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f8074268513571775e154294729b66fc0ccbdbeceb5c8f6eaa9670664e40c03d
MD5 bd01afbad13c4ab07f6e7dec66b02fd7
BLAKE2b-256 42aa308a94956501bf8a9a3d389e2c0e5cb405acc81780f7c16ba3898ae08fc3

See more details on using hashes here.

File details

Details for the file panns_inference-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for panns_inference-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97f6b56b6c9467cf00e21f041e1f88933188c65c1b5ca64eeb3c92e37fb27fc2
MD5 534116798fb5297a96de6141bf065eeb
BLAKE2b-256 adac0558484d9b5383125912b1cedeb95b1f7e928c2b0781f52d77b068f0ba3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page