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 GUI-based audio player with support for a large variety of formats

Miza-Player A GUI-based audio player with support for a large variety of formats, able to play from web-hosted media platforms such as YouTube, includ

Thomas Xin 3 Dec 14, 2022
Xbot-Music - Bot Play Music and Video in Voice Chat Group Telegram

XBOT-MUSIC A Telegram Music+video Bot written in Python using Pyrogram and Py-Tg

Fariz 2 Jan 20, 2022
Synchronize a local directory of songs' (MP3, MP4) metadata (genre, ratings) and playlists with a Plex server.

PlexMusicSync Synchronize a local directory of songs' (MP3, MP4) metadata (genre, ratings) and playlists (m3u, m3u8) with a Plex server. The song file

Tom Goetz 9 Jul 07, 2022
Telegram Bot to play music in VoiceChat with Channel Support and autostarts Radio.

VCPlayerBot Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live streams, YouTube videos and telegram media

Abdisamad Omar Mohamed 1 Oct 15, 2021
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
🎵 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
Code for csig audio deepfake detection

FMFCC Audio Deepfake Detection Solution This repo provides an solution for the 多媒体伪造取证大赛. Our solution achieve the 1st in the Audio Deepfake Detection

BokingChen 9 Jun 04, 2022
MUSIC-AVQA, CVPR2022 (ORAL)

Audio-Visual Question Answering (AVQA) PyTorch code accompanies our CVPR 2022 paper: Learning to Answer Questions in Dynamic Audio-Visual Scenarios (O

44 Dec 23, 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
Stevan KZ 1 Oct 27, 2021
Musillow is a music recommender app that finds songs similar to your favourites.

MUSILLOW The music recommender app Check it out now!!! View Demo · Report Bug · Request Feature About The App Musillow is a music recommender app that

3 Feb 03, 2022
Suyash More 111 Jan 07, 2023
Python interface to the WebRTC Voice Activity Detector

py-webrtcvad This is a python interface to the WebRTC Voice Activity Detector (VAD). It is compatible with Python 2 and Python 3. A VAD classifies a p

John Wiseman 1.5k Dec 22, 2022
Okaeri-Music is a telegram music bot project, allow you to play music on voice chat group telegram.

Okaeri-Music is a telegram bot project that's allow you to play music on telegram voice chat group

Wahyusaputra 1 Dec 22, 2021
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
Bot Music Pintar. Created by Rio

🎶 Rio Music 🎶 Kalo Fork Star Ya Bang Hehehe Requirements 📝 FFmpeg NodeJS nodesource.com Python 3.8+ or 3.7 PyTgCalls Generate String Using Replit ⤵

RioProjectX 7 Jun 15, 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 09, 2023
In this project we can see how we can generate automatic music using character RNN.

Automatic Music Genaration Table of Contents Project Description Approach towards the problem Limitations Libraries Used Summary Applications Referenc

Pronay Ghosh 2 May 27, 2022
Simple discord bot by @merive 🤖

Parzibot Powerful and Useful Discord Bot on Python. The source code of the bot is available to everyone. Parzibot uses English language. This is free

merive_ 3 Dec 28, 2022
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