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
Enhanced Audio Player for Discord

Discodo is an enhanced audio player for discord

Mary 42 Oct 05, 2022
Minimal command-line music player written in Python

pyms Minimal command-line music player written in Python. Designed with elegance and minimalism. Resizes dynamically with your terminal. Dependencies

12 Sep 23, 2022
ianZiPu is a way to write notation for Guqin (古琴) music.

PyBetween Wrapper for Between - 비트윈을 위한 파이썬 라이브러리 Legal Disclaimer 오직 교육적 목적으로만 사용할수 있으며, 비트윈은 VCNC의 자산입니다. 악의적 공격에 이용할시 처벌 받을수 있습니다. 사용에 따른 책임은 사용자가

Nancy Yi Liang 8 Nov 25, 2022
Algorithmic and AI MIDI Drums Generator Implementation

Algorithmic and AI MIDI Drums Generator Implementation

Tegridy Code 8 Dec 30, 2022
🎵 A music bot for discord servers!

music bot A music bot for Discord Servers Features Play songs in your discord server Get the lyrics without going on a web explorer Commands Command P

1 Jul 25, 2022
Spotifyd - An open source Spotify client running as a UNIX daemon.

Spotifyd An open source Spotify client running as a UNIX daemon. Spotifyd streams music just like the official client, but is more lightweight and sup

8.5k Jan 09, 2023
Suyash More 111 Jan 07, 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 06, 2023
commonfate 📦commonfate 📦 - Common Fate Model and Transform.

Common Fate Transform and Model for Python This package is a python implementation of the Common Fate Transform and Model to be used for audio source

Fabian-Robert Stöter 18 Jan 08, 2022
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
Bot duniya Music Player

Bot duniya Music Player Requirements 📝 FFmpeg (Latest) NodeJS nodesource.com (NodeJS 17+) Python (3.10+) PyTgCalls (Lastest) 2nd Telegram Account (ne

Aman Vishwakarma 16 Oct 21, 2022
convert-to-opus-cli is a Python CLI program for converting audio files to opus audio format.

convert-to-opus-cli convert-to-opus-cli is a Python CLI program for converting audio files to opus audio format. Installation Must have installed ffmp

4 Dec 21, 2022
Manipulate audio with a simple and easy high level interface

Pydub Pydub lets you do stuff to audio in a way that isn't stupid. Stuff you might be looking for: Installing Pydub API Documentation Dependencies Pla

James Robert 6.6k Jan 01, 2023
A Python wrapper for the high-quality vocoder "World"

PyWORLD - A Python wrapper of WORLD Vocoder Linux Windows WORLD Vocoder is a fast and high-quality vocoder which parameterizes speech into three compo

Jeremy Hsu 583 Dec 15, 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
Deep learning transformer model that generates unique music sequences.

music-ai Deep learning transformer model that generates unique music sequences. Abstract In 2017, a new state-of-the-art was published for natural lan

xacer 6 Nov 19, 2022
Carnatic Notes Predictor for audio files

Carnatic Notes Predictor for audio files Link for live application: https://share.streamlit.io/pradeepak1/carnatic-notes-predictor-for-audio-files/mai

1 Nov 06, 2021
music library manager and MusicBrainz tagger

beets Beets is the media library management system for obsessive music geeks. The purpose of beets is to get your music collection right once and for

beetbox 11.3k Dec 31, 2022
This is an AI that runs in the terminal. It is a voice assistant that can do common activities and can also help in your coding doubts like

This is an AI that runs in the terminal. It is a voice assistant that can do common activities and can also help in your coding doubts like

OneBit 1 Nov 05, 2021
We built this fully functioning Music player in Python. The music player allows you to play/pause and switch to different songs easily.

We built this fully functioning Music player in Python. The music player allows you to play/pause and switch to different songs easily.

1 Nov 19, 2021