A plug-and-play tool to detect and rate hallucinations in ASR outputs.
Project description
JSRify - ASR Hallucination Detection Tool
A comprehensive plug-and-play tool to detect and rate hallucinations in Automatic Speech Recognition (ASR) outputs. This library provides robust evaluation of ASR systems by introducing various types of noise and analyzing how they affect transcription accuracy and hallucination rates.
Author: Anshit Mukherjee
Contact: anshitmukherjee1@gmail.com
Features
- Multiple Noise Types: Synthetic noise (Gaussian, impulse, frequency shift) and real-world noise from MUSAN dataset
- Comprehensive Metrics: Binary and multi-class confusion matrices, WER components, confidence analysis
- Visualization: Heatmaps and detailed analysis plots
- Flexible Evaluation: Support for multiple SNR levels and noise categories
- Easy Integration: Simple API for running complete evaluation pipelines
- Model Agnostic: Use with any ASR model by providing your own transcription function
Installation
Install the latest release from PyPI:
pip install jsrify
Or, for development:
pip install -e .
Quick Start
from jsrify import run_pipeline
# Run the complete evaluation pipeline
run_pipeline()
Usage
Model-Agnostic Evaluation
You can use any ASR model with this library! Simply provide a function that takes an audio path and returns a transcript string.
Example: Using Your Own ASR Model
from jsrify.usage import batch_process
def my_asr_transcribe(audio_path):
# Your ASR model logic here
return "transcribed text"
sample_files, all_binary_confusions, multiclass_counter = batch_process(
audio_dir='path/to/Audio',
transcript_dir='path/to/Transcripts',
output_folder='path/to/output',
transcribe_fn=my_asr_transcribe, # Pass your own function here
sample_size=10,
png_output=True
)
Example: Using Whisper (Convenience Wrapper)
from jsrify.usage import batch_process, whisper_transcribe_fn_factory
whisper_fn = whisper_transcribe_fn_factory(model_size='small')
sample_files, all_binary_confusions, multiclass_counter = batch_process(
audio_dir='path/to/Audio',
transcript_dir='path/to/Transcripts',
output_folder='path/to/output',
transcribe_fn=whisper_fn, # Use the provided Whisper wrapper
sample_size=10,
png_output=True
)
Basic Usage
The library automatically:
- Loads random audio-transcript pairs from your dataset
- Applies various noise types and levels
- Runs ASR transcription using your provided function
- Calculates hallucination metrics
- Generates visualization reports (if requested)
Custom Configuration
from jsrify.confusion_matrices import binary_confusion_matrix, multiclass_confusion_matrix
ground_truth = "your ground truth text"
hypothesis = my_asr_transcribe("path/to/audio.wav")
confusion_matrix = binary_confusion_matrix(ground_truth, hypothesis)
Advanced: Custom Usage Functions
You can also use the importable usage functions for more control:
from jsrify.usage import run_basic_example
transcript, confusion_matrix = run_basic_example(
transcribe_fn=my_asr_transcribe,
audio_path='path/to/audio.wav',
ground_truth='your ground truth text'
)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For questions, suggestions, or contributions, please contact:
Anshit Mukherjee
anshitmukherjee1@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsrify-0.1.2.tar.gz.
File metadata
- Download URL: jsrify-0.1.2.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c384299d9c60f04a6acbd0bf55adab6b5e81d891f92c3134f45b2f8cfa9ca35
|
|
| MD5 |
72baab8c5075a5fa06a95914bbd52472
|
|
| BLAKE2b-256 |
bd8a305674ba25760135745fb4a5d75ce9f5f5d94626b59284a02efe6a65bd8d
|
File details
Details for the file jsrify-0.1.2-py3-none-any.whl.
File metadata
- Download URL: jsrify-0.1.2-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b0e4dfa6bde93daa2b245ae5b5b0ebbb0267f6a1a3c8347069615aae9ca5f3c
|
|
| MD5 |
41d3e95eb531485b36971599f34b73d2
|
|
| BLAKE2b-256 |
af4fefc8149f68b9ac7a955cd4586ac5f512f91c89fee3911bdcd22683e03a10
|