Skip to main content

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.

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

pip install -r requirements.txt

Or install the package:

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:

  1. Loads random audio-transcript pairs from your dataset
  2. Applies various noise types and levels
  3. Runs ASR transcription using your provided function
  4. Calculates hallucination metrics
  5. 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'
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsrify-0.1.1.tar.gz (28.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsrify-0.1.1-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file jsrify-0.1.1.tar.gz.

File metadata

  • Download URL: jsrify-0.1.1.tar.gz
  • Upload date:
  • Size: 28.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for jsrify-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d86a155be6ef201c88d0354c63b2fe40bf34943972cde1aa32e8ed05f806b520
MD5 a277de971785d098aea5ecc918a02bc9
BLAKE2b-256 f18939959a4e6e20b84e6232a9fce22032e89029afd8aa2a3549d9d0e9862875

See more details on using hashes here.

File details

Details for the file jsrify-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jsrify-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for jsrify-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e0c0e34ec8ae5cbea8a8ecc03cd5a80fe3d7442913a9fb45834f2bb7846759d
MD5 e38c2d77ee6025f8fbe7f0807ae94427
BLAKE2b-256 984a57b05493785ec1f11c5ea98e5a49804ce9ea84fb620b9d9510929e1bcf91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page