{"library":"pesq","title":"PESQ Score Calculator","description":"pesq is a Python wrapper for the Perceptual Evaluation of Speech Quality (PESQ) metric, implementing the ITU-T P.862 standard. It supports both narrow-band ('nb') and wide-band ('wb') calculations, providing an objective measure of speech quality. The current version is 0.0.4, with releases occurring infrequently but introducing new features like multiprocessing support.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pesq"],"cli":null},"imports":["from pesq import pesq","from pesq import pesq_batch"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nfrom pesq import pesq\n\n# Define sampling rate and generate dummy audio signals (16 kHz, 3 seconds)\nfs = 16000\nduration = 3 # seconds\nt = np.linspace(0, duration, int(fs * duration), endpoint=False)\n\n# Reference signal (e.g., clean speech)\nref_signal = (0.5 * np.sin(2 * np.pi * 440 * t)).astype(np.float32)\n\n# Degraded signal (e.g., speech with noise or distortion)\ndeg_signal = (0.5 * np.sin(2 * np.pi * 440 * t + 0.1) + 0.1 * np.random.randn(len(t))).astype(np.float32)\n\n# Ensure signals are 16-bit PCM (by scaling to int16 range) if not already\n# The library expects float32, but underlying PESQ is 16-bit. \n# For this example, float32 is fine as it will be handled internally.\n\n# Calculate Wide-Band PESQ score\nscore_wb = pesq(fs, ref_signal, deg_signal, 'wb')\nprint(f\"PESQ Wide-Band (wb) score: {score_wb:.2f}\")\n\n# Calculate Narrow-Band PESQ score (requires adjusting signals if necessary)\n# score_nb = pesq(fs, ref_signal, deg_signal, 'nb')\n# print(f\"PESQ Narrow-Band (nb) score: {score_nb:.2f}\")\n\n# The `pesq` function also accepts file paths directly:\n# import soundfile as sf\n# import os\n# sf.write('ref.wav', ref_signal, fs, subtype='PCM_16')\n# sf.write('deg.wav', deg_signal, fs, subtype='PCM_16')\n# score_files = pesq(fs, 'ref.wav', 'deg.wav', 'wb')\n# print(f\"PESQ from files: {score_files:.2f}\")\n# os.remove('ref.wav'); os.remove('deg.wav')","lang":"python","description":"This quickstart demonstrates how to calculate a PESQ score using NumPy arrays for reference and degraded audio signals. It highlights the use of the `pesq` function with a specified sampling rate and mode ('wb' for wide-band). The library internally handles the necessary conversions, but input characteristics are crucial.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}