A python package for calculating the PESQ.

Related tags

Audiopython-pesq
Overview

PyPESQ (WIP)

Pypesq is a python wrapper for the PESQ score calculation C routine. It only can be used in evaluation purpose.

INSTALL

pip install https://github.com/vBaiCai/python-pesq/archive/master.zip

or

pip install pypesq

HOW TO USE

import soundfile as sf
from pypesq import pesq

ref, sr = sf.read(...)
deg, sr = sf.read(...)

score = pesq(ref, deg, sr)
print(score)

NOTICE:

OWNERS of PESQ ARE:

  1. British Telecommunications plc (BT), all rights assigned to Psytechnics Limited
  2. Royal KPN NV, all rights assigned to OPTICOM GmbH

REFERENCES:

TODO

  1. More test.
  2. I'm not sure whether to add the wav normalization.

HINT

The PESQ contain 3 types of values: NB PESQ MOS, NB MOS LQO, WB MOS LQO. This package only return the NB PESQ MOS score, which represents the Raw MOS for narrowband handset listening.

Comments
  • wrong score for wideband signal

    wrong score for wideband signal

    I tested this code with the audio files from https://github.com/ludlows/python-pesq (i.e. speech.wav vs speech_bab_0dB.wav) and got the score 1.9688572883605957. There was said, the score should be 1.0832337141036987 for wide band pesq and 1.6072081327438354 for narrow band pesq.

    Looking at the examples in https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/47333/versions/3/previews/test_pesq2_mtlb.m/index.html there are 3 values that can be calculated:

        %    NB PESQ MOS = 1.969
        %    NB MOS LQO  = 1.607
        %    WB MOS LQO  = 1.083
    

    I would expect to get the MOS LQO without downsampling.

    Is it intended to always return the NB PESQ MOS? If yes, do you have a reason for that?

    opened by boeddeker 5
  • PESQ score for the .raw file

    PESQ score for the .raw file

    Thanks for the wonderful code. In your example, I guess it is for .wav file. But for the audio in .raw, is this function still valid? And what is the correct reading function for .raw file.

    Thanks for your help.

    opened by benlin1996 2
  • Problem when using setup.py

    Problem when using setup.py

    Thanks for the useful code.

    When I try to run command "python setup.py", there is an error. What is the right command for running setup.py?

    Another question is about missing pesq_core module when running init.py. Does this problem fixed after I run setup.py correctly?

    Thanks for your help

    opened by benlin1996 2
  • PESQ between noisy and enhanced version of speech.

    PESQ between noisy and enhanced version of speech.

    Hello everyone, If I do not have a clean version of speech . Can I compute the PESQ between the noisy original speech and the enhanced speech? what does that mean ? Best Regards.

    opened by BilalDendani 2
  • how do I make it apply to python2.7

    how do I make it apply to python2.7

    first of all, i'm very glad to found this project and thanks for you contribution. but my envirment is python 2.7 and i found you project is depending on python 3+. so how do i make it apply to python 2.7? // this may be supported to python 3+, because when i run 'python setup.py install' and i got some errors : pypesq/pesq.c(21) : error C2079: 'pesqmodule' uses undefined struct 'PyModuleDef' pypesq/pesq.c(22) : error C2065: 'PyModuleDef_HEAD_INIT' : undeclared identifier pypesq/pesq.c(22) : error C2099: initializer is not a constant pypesq/pesq.c(23) : warning C4047: 'initializing' : 'int' differs in levels of indirection from 'char [10]' pypesq/pesq.c(24) : error C2078: too many initializers pypesq/pesq.c(31) : warning C4013: 'PyModule_Create' undefined; assuming extern returning int pypesq/pesq.c(31) : warning C4098: 'PyInit_pesq_core' : 'void' function returning a value pypesq/pesq.c(54) : error C2143: syntax error : missing ';' before 'type' pypesq/pesq.c(59) : error C2065: 'pesq' : undeclared identifier pypesq/pesq.c(60) : error C2065: 'pesq' : undeclared identifier

    i found it at: static struct PyModuleDef pesqmodule = { PyModuleDef_HEAD_INIT, "pesq_core", module_docstring, -1, module_methods };

    bug 
    opened by amoxuk 2
  • Trigger conditions err_info->Nutterances < 1

    Trigger conditions err_info->Nutterances < 1

        if (err_info->Nutterances < 1)
        {
            /*printf ("Processing error!\n");*/
            /*exit (1);*/
            PyErr_SetString(PyExc_RuntimeError, "processing error!");
        }
    

    Log print warnings.warn('Processing Error! return NaN........') use older version, i see it stop at conditions err_info->Nutterances < 1 processing error! WHY? but if i change metric="pesq" to metric="" ,training is ok!

    opened by luyan66 1
  • fix bug: fix the duplicate symbol error

    fix bug: fix the duplicate symbol error

    error message:

     clang++ -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk build/temp.macosx-10.15-x86_64-3.7/pypesq/pesq.o build/temp.macosx-10.15-x86_64-3.7/pypesq/dsp.o build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqdsp.o build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqio.o build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqmain.o build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqmod.o -L/usr/local/lib -L/usr/local/opt/[email protected]/lib -L/usr/local/opt/sqlite/lib -o build/lib.macosx-10.15-x86_64-3.7/pesq_core.cpython-37m-darwin.so
        duplicate symbol '_Nb' in:
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesq.o
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqio.o
        duplicate symbol '_Nb' in:
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesq.o
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqdsp.o
        duplicate symbol '_Nb' in:
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesq.o
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqmain.o
        duplicate symbol '_InIIR_Nsos' in:
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqdsp.o
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqmod.o
        duplicate symbol '_Nb' in:
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesq.o
            build/temp.macosx-10.15-x86_64-3.7/pypesq/pesqmod.o
        ld: 5 duplicate symbols for architecture x86_64
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        error: command 'clang++' failed with exit status 1
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/h0/w7jzmrn91g123jqshs7t4nwc0000gq/T/pip-install-fa7q3bwy/pypesq/setup.py'"'"'; __file__='"'"'/private/var/folders/h0/w7jzmrn91g123jqshs7t4nwc0000gq/T/pip-install-fa7q3bwy/pypesq/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/h0/w7jzmrn91g123jqshs7t4nwc0000gq/T/pip-record-78fa2r57/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/pypesq Check the logs for full command output.
    

    I fix the bug the duplicate symbol happens.

    opened by qyou 1
  • PESQ

    PESQ

    Hi vBaiCai! thanks a lot for sharing this. I have been trying to implement PESQ. I was wondering from the code:

    from pypesq import pesq ref, sr = sf.read(...) deg, sr = sf.read(...)

    what exactly is suppose to be the input to sf.read.

    Thank you in advance!

    opened by ahaanparekh 1
  • Error with PyPi

    Error with PyPi

    When installing, I get:

       In file included from /Users/shamoon/Library/Python/3.7/lib/python/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830:
        /Users/shamoon/Library/Python/3.7/lib/python/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with "          "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
        #warning "Using deprecated NumPy API, disable it with " \
         ^
        pypesq/pesq.c:5:10: fatal error: 'pesq.h' file not found
        #include "pesq.h"
                 ^~~~~~~~
        1 warning and 1 error generated.
        error: command 'clang' failed with exit status 1
        Running setup.py install for pypesq ... error
    

    Not sure why that's happening, because pesq.h is clearly there. Any help?

    opened by shamoons 1
  • my comput kill the prcess when  I calculation PESQ of wav file

    my comput kill the prcess when I calculation PESQ of wav file

    Hi Jingdong Li: this is my code : ref, _ = librosa.load(fliepath_ref,sr=sr,mono=True) deg, _ = librosa.load(fliepath_deg,sr=sr,mono=True) pesq(ref,deg)

    thanks

    opened by wangyang2014 0
  • ValueError

    ValueError

    Hope for some one's help. Thank you! Code: from pydub import AudioSegment from pypesq import pesq sound1 = AudioSegment.from_file('D:/Test/speech.wav', 'wav') sound2 = AudioSegment.from_file('D:/Test/speech_bab_0dB.wav', 'wav') score = pesq(sound1, sound2, 16000) print(score) Error: ValueError Traceback (most recent call last) ----> 5 score = pesq(sound1, sound2, 16000) ---> 21 max_sample = np.max(np.abs(np.array([ref, deg])))

    ValueError: could not broadcast input array from shape (3100,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) into shape (3100,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)

    opened by emmalt 0
  • cant print

    cant print

    a,sr=sf.read('E:/speech/sliced_test_clean/S_01_01.wav') b,sr=sf.read('E:/speech/sliced_test_-5/S_01_01.wav') score=pesq(a,b,sr) print(score) there is no print

    opened by hidehowever1 19
  • The PESQ score is  nan

    The PESQ score is nan

    Hi everyone. I am asking about the meaning of nan PESQ score. After some successful compute of PESQ score for my speech samples I got the following error for the residual samples

    anaconda3/lib/python3.6/site-packages/pypesq-1.0-py3.6-linux-x86_64.egg/pypesq/init.py:16: RuntimeWarning: invalid value encountered in true_divide deg = 0.999*deg/np.max(np.abs(deg)) Thank you.

    opened by BilalDendani 3
Owner
Jingdong Li
Speech Enhancement | Speech Synthesis | Gluttonous Person
Jingdong Li
A library for augmenting annotated audio data

muda A library for Musical Data Augmentation. muda package implements annotation-aware musical data augmentation, as described in the muda paper. The

Brian McFee 214 Nov 22, 2022
Voicefixer aims at the restoration of human speech regardless how serious its degraded.

Voicefixer aims at the restoration of human speech regardless how serious its degraded.

Leo 324 Dec 26, 2022
Synthesia but open source, made in python and free

PyPiano Synthesia but open source, made in python and free Requirements are in requirements.txt If you struggle with installation of pyaudio, run : pi

DaCapo 11 Nov 06, 2022
This bot can stream audio or video files and urls in telegram voice chats

Voice Chat Streamer This bot can stream audio or video files and urls in telegram voice chats :) 🎯 Follow me and star this repo for more telegram bot

WiskeyWorm 4 Oct 09, 2022
A bot that can play music on Telegram Group and Channel Voice Chats

DaisyXmusic ❤ is the best and only Telegram VC player with playlists, Multi Playback, Channel play and more

TeamOfDaisyX 20 Jun 11, 2021
Reading list for research topics in sound event detection

Sound event detection aims at processing the continuous acoustic signal and converting it into symbolic descriptions of the corresponding sound events present at the auditory scene.

Soham 64 Jan 05, 2023
Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications

A Python library for audio feature extraction, classification, segmentation and applications This doc contains general info. Click here for the comple

Theodoros Giannakopoulos 5.1k Jan 02, 2023
🎵 A repository for manually annotating files to create labeled acoustic datasets for machine learning.

🎵 A repository for manually annotating files to create labeled acoustic datasets for machine learning.

Jim Schwoebel 28 Dec 22, 2022
❤️ This Is The EzilaXMusicPlayer Advaced Repo 🎵

Telegram EzilaXMusicPlayer Bot 🎵 A bot that can play music on telegram group's voice Chat ❤️ Requirements 📝 FFmpeg NodeJS nodesource.com Python 3.7+

Sadew Jayasekara 11 Nov 12, 2022
Using python to generate a bat script of repetitive lines of code that differ in some way but can sort out a group of audio files according to their common names

Batch Sorting Using python to generate a bat script of repetitive lines of code that differ in some way but can sort out a group of audio files accord

David Mainoo 1 Oct 29, 2021
MusicBrainz Picard

MusicBrainz Picard MusicBrainz Picard is a cross-platform (Linux/Mac OS X/Windows) application written in Python and is the official MusicBrainz tagge

MetaBrainz Foundation 3k Dec 31, 2022
Audio augmentations library for PyTorch for audio in the time-domain

Audio augmentations library for PyTorch for audio in the time-domain, with support for stochastic data augmentations as used often in self-supervised / contrastive learning.

Janne 166 Jan 08, 2023
[Singing Log] Let your program learn to sing!

[Singing Log] Let your program learn to sing! You must have thought this was changelog when you saw the English title, but it's not, it's chànggēlog. What it does is allow your program to print logs

黄巍 22 Sep 03, 2022
Open-Source bot to play songs in your Telegram's Group Voice Chat. Powered by @Akki_ThePro

VcPlayer Telegram Voice-Chat Bot [PyTGCalls] ⇝ Requirements ⇜ Account requirements A Telegram account to use as the music bot, You cannot use regular

Akki ThePro 2 Dec 25, 2021
Open-Source Tools & Data for Music Source Separation: A Pragmatic Guide for the MIR Practitioner

Open-Source Tools & Data for Music Source Separation: A Pragmatic Guide for the MIR Practitioner

IELab@ Korea University 0 Nov 12, 2021
A rofi-blocks script that searches youtube and plays the selected audio on mpv.

rofi-ytm A rofi-blocks script that searches youtube and plays the selected audio on mpv. To use the script, run the following command rofi -modi block

Cliford 26 Dec 21, 2022
All-In-One Digital Audio Workstation and Plugin Suite

How to install Windows Mac OS X Fedora Ubuntu How to Build Debian and Ubuntu Fedora All Other Linux Distros Mac OS X Windows What is MusiKernel? MusiK

j3ffhubb 111 Sep 21, 2021
spafe: Simplified Python Audio-Features Extraction

spafe aims to simplify features extractions from mono audio files. The library can extract of the following features: BFCC, LFCC, LPC, LPCC, MFCC, IMFCC, MSRCC, NGCC, PNCC, PSRCC, PLP, RPLP, Frequenc

Ayoub Malek 310 Jan 01, 2023
PatrikZero's CS:GO Hearing protection

Program that lowers volume when you die and get flashed in CS:GO. It aims to lower the chance of hearing damage by reducing overall sound exposure. Uses game state integration. Anti-cheat safe.

Patrik Žúdel 224 Dec 04, 2022
cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python

audioread Decode audio files using whichever backend is available. The library currently supports: Gstreamer via PyGObject. Core Audio on Mac OS X via

beetbox 419 Dec 26, 2022