refactor versa in OO (major update)#37
Open
ftshijt wants to merge 16 commits intowavlab-speech:mainfrom
Open
Conversation
There was a problem hiding this comment.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor codebase for better interface:
Fully supported metrics: