Skip to content

refactor versa in OO (major update)#37

Open
ftshijt wants to merge 16 commits intowavlab-speech:mainfrom
ftshijt:refactor
Open

refactor versa in OO (major update)#37
ftshijt wants to merge 16 commits intowavlab-speech:mainfrom
ftshijt:refactor

Conversation

@ftshijt
Copy link
Contributor

@ftshijt ftshijt commented Jun 16, 2025

Refactor codebase for better interface:

  • Introduce base metric for various setup
  • Complete meta information within the metric setup
  • MetricRegistry for automatic metric update
  • MetricFactory for building metric
  • MetricSuite for grouped modeling
  • Improved dependency control

Fully supported metrics:

  • asr_matching
  • srmr
  • asvspoof_score
  • audiobox_aesthetics
  • cdpam
  • dpam
  • chroma_alignment
  • emo_similarity
  • emo_vad
  • nisqa
  • discrete_speech
  • owsm_lid
  • noresqa

@ftshijt ftshijt requested a review from Copilot June 16, 2025 17:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the versa codebase to adopt an object‐oriented design for metrics, replacing function‐based implementations with class-based ones. Key changes include:

  • Introducing class-based SRMRMetric and ASRMatchMetric along with their auto-registration functions.
  • Updating the MetricRegistry, MetricFactory, and MetricSuite patterns to support the new design.
  • Adapting the test pipelines and module initialization to load and use the new metric classes.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
versa/utterance_metrics/srmr.py Refactored SRMR metric into a class-based implementation with improved configuration.
versa/utterance_metrics/asr_matching.py Replaced function-based ASR matching with a class-based version and updated its setup.
versa/metrics.py Minor formatting adjustments to support new changes.
versa/definition.py Added and updated abstract base classes, registry, factory, and suite for metrics.
versa/init.py Updated imports to register and export the new metric classes instead of legacy functions.
test/test_pipeline/test_srmr.py Adapted the SRMR test pipeline to use the registry and new scoring API.
test/test_pipeline/test_asr_match.py Adapted the ASR match test pipeline to use the registry and new scoring API.
Comments suppressed due to low confidence (4)

versa/utterance_metrics/asr_matching.py:122

  • The function 'opcodes' is used here but is not imported or defined in this module. Consider importing it from difflib (e.g., using SequenceMatcher.get_opcodes()) or defining it appropriately.
for op, ref_st, ref_et, inf_st, inf_et in opcodes(ref_chars, pred_chars):

versa/utterance_metrics/asr_matching.py:95

  • The 'torch' module is used in this context but there is no corresponding import statement. Please add 'import torch' at the top of the module to ensure proper functionality.
with torch.no_grad():

versa/utterance_metrics/asr_matching.py:92

  • The 'librosa' module is used for resampling operations in this file but is not imported. Please add 'import librosa' at the beginning of the file.
if fs != TARGET_FS:

versa/utterance_metrics/asr_matching.py:69

  • The 'whisper' module is utilized to load the model, yet there is no import for it in the diff. Please add 'import whisper' at the top of the module to avoid runtime errors.
self.model = whisper.load_model(self.model_tag, device=self.device)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants