A python package for calculating the PESQ.

Related tags

Audio python-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
Expressive Digital Signal Processing (DSP) package for Python

AudioLazy Development Last release PyPI status Real-Time Expressive Digital Signal Processing (DSP) Package for Python! Laziness and object representa

Danilo de Jesus da Silva Bellini 573 Feb 8, 2021
Sync Toolbox - Python package with reference implementations for efficient, robust, and accurate music synchronization based on dynamic time warping (DTW)

Sync Toolbox - Python package with reference implementations for efficient, robust, and accurate music synchronization based on dynamic time warping (DTW)

Meinard Mueller 66 Jan 2, 2023
This is a python package that turns any images into MIDI files that views the same as them

image_to_midi This is a python package that turns any images into MIDI files that views the same as them. This package firstly convert the image to AS

Rainbow Dreamer 4 Mar 10, 2022
Pyroomacoustics is a package for audio signal processing for indoor applications. It was developed as a fast prototyping platform for beamforming algorithms in indoor scenarios.

Summary Pyroomacoustics is a software package aimed at the rapid development and testing of audio array processing algorithms. The content of the pack

Audiovisual Communications Laboratory 1k Jan 9, 2023
Voice package for Pycord adding extra features.

VoiceIO Voice package for Pycord adding extra features. Example Down bellow is an example of what you can currently do. import voiceio process = voic

pycord 1 Dec 24, 2021
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
Audio fingerprinting and recognition in Python

dejavu Audio fingerprinting and recognition algorithm implemented in Python, see the explanation here: How it works Dejavu can memorize audio by liste

Will Drevo 6k Jan 6, 2023
Python library for audio and music analysis

librosa A python package for music and audio analysis. Documentation See https://librosa.org/doc/ for a complete reference manual and introductory tut

librosa 5.6k Jan 6, 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 2, 2023
Scalable audio processing framework written in Python with a RESTful API

TimeSide : scalable audio processing framework and server written in Python TimeSide is a python framework enabling low and high level audio analysis,

Parisson 340 Jan 4, 2023
nicfit 425 Jan 1, 2023
Python module for handling audio metadata

Mutagen is a Python module to handle audio metadata. It supports ASF, FLAC, MP4, Monkey's Audio, MP3, Musepack, Ogg Opus, Ogg FLAC, Ogg Speex, Ogg The

Quod Libet 1.1k Dec 31, 2022
Read music meta data and length of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python 2 or 3

tinytag tinytag is a library for reading music meta data of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python Install pip install tinytag

Tom Wallroth 577 Dec 26, 2022
Telegram Voice-Chat Bot Written In Python Using Pyrogram.

Telegram Voice-Chat Bot Telegram Voice-Chat Bot To Play Music From Various Sources In Your Group Support All linux based os. Windows Mac Diagram Requi

TheHamkerCat 314 Dec 29, 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 359 Feb 15, 2021
Python wrapper around sox.

pysox Python wrapper around sox. Read the Docs here. This library was presented in the following paper: R. M. Bittner, E. J. Humphrey and J. P. Bello,

Rachel Bittner 446 Dec 7, 2022
Python I/O for STEM audio files

stempeg = stems + ffmpeg Python package to read and write STEM audio files. Technically, stems are audio containers that combine multiple audio stream

Fabian-Robert Stöter 72 Dec 23, 2022
Read music meta data and length of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python 2 or 3

tinytag tinytag is a library for reading music meta data of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python Install pip install tinytag

Tom Wallroth 435 Feb 17, 2021
Python library for handling audio datasets.

AUDIOMATE Audiomate is a library for easy access to audio datasets. It provides the datastructures for accessing/loading different datasets in a gener

Matthias 121 Nov 27, 2022