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 python wrapper for REAPER

pyreaper A python wrapper for REAPER (Robust Epoch And Pitch EstimatoR) Installation pip install pyreaper Demonstration notebnook http://nbviewer.jupy

Ryuichi Yamamoto 56 Dec 27, 2022
Sparse Beta-Divergence Tensor Factorization Library

NTFLib Sparse Beta-Divergence Tensor Factorization Library Based off of this beta-NTF project this library is specially-built to handle tensors where

Stitch Fix Technology 46 Jan 08, 2022
An AI for Music Generation

An AI for Music Generation

Hao-Wen Dong 1.3k Dec 31, 2022
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
Learn chords with your MIDI keyboard !

miditeach miditeach is a music learning tool that can be used to practice your chords skills with a midi keyboard 🎹 ! Features Midi keyboard input se

Alexis LOUIS 3 Oct 20, 2021
An 8D music player made to enjoy Halloween this year!🤘

HAPPY HALLOWEEN buddy! Split Player Hello There! Welcome to SplitPlayer... Supposed To Be A 8DPlayer.... You Decide.... It can play the ordinary audio

Akshat Kumar Singh 1 Nov 04, 2021
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
Some utils for auto speech recognition

About Some utils for auto speech recognition. Utils Util Description Script Reset audio Reset sample rate, sample width, etc of audios.

1 Jan 24, 2022
Audio processor to map oracle notes in the VoG raid in Destiny 2 to call outs.

vog_oracles Audio processor to map oracle notes in the VoG raid in Destiny 2 to call outs. Huge thanks to mzucker on GitHub for the note detection cod

19 Sep 29, 2022
Code to work with wave files!

Code to work with wave files!

Mohammad Dori 3 Jul 15, 2022
An audio-solving python funcaptcha solving module

funcapsolver funcapsolver is a funcaptcha audio-solving module, which allows captchas to be interacted with and solved with the use of google's speech

Acier 8 Nov 21, 2022
:sound: Play and Record Sound with Python :snake:

Play and Record Sound with Python This Python module provides bindings for the PortAudio library and a few convenience functions to play and record Nu

spatialaudio.net 750 Dec 31, 2022
Spotipy - Player de música simples em Python

Spotipy Player de música simples em Python, utilizando a biblioteca Pysimplegui para a interface gráfica. Este tocador é bastante simples em si, mas p

Adelino Almeida 4 Feb 28, 2022
This Bot can extract audios and subtitles from video files

Send any valid video file and the bot shows you available streams in it that can be extracted!!

TroJanzHEX 56 Nov 22, 2022
Pyrogram bot to automate streaming music in voice chats

Pyrogram bot to automate streaming music in voice chats Help If you face an error, want to discuss this project or get support for it, join it's group

Roj 124 Oct 21, 2022
Speech recognition module for Python, supporting several engines and APIs, online and offline.

SpeechRecognition Library for performing speech recognition, with support for several engines and APIs, online and offline. Speech recognition engine/

Anthony Zhang 6.7k Jan 08, 2023
Supysonic is a Python implementation of the Subsonic server API.

Supysonic Supysonic is a Python implementation of the Subsonic server API. Current supported features are: browsing (by folders or tags) streaming of

Alban 228 Nov 19, 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
Algorithmic and AI MIDI Drums Generator Implementation

Algorithmic and AI MIDI Drums Generator Implementation

Tegridy Code 8 Dec 30, 2022
FPGA based USB 2.0 high speed audio interface featuring multiple optical ADAT inputs and outputs

ADAT USB Audio Interface FPGA based USB 2.0 High Speed audio interface featuring multiple optical ADAT inputs and outputs Status / current limitations

Hans Baier 78 Dec 31, 2022