refactor: Unify audio input parameter naming#887
Conversation
- 将多个类中的 `audio_path` 参数重命名为 `audio_input`,以提高一致性和可读性。 - 更新相关文档和注释,确保参数说明与实际代码一致。 - 优化音频处理逻辑,确保在不同类中对音频输入的处理方式一致。 这些改动增强了代码的可维护性,减少了潜在的混淆。
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
This PR refactors the audio input parameter naming across ASR classes, renaming audio_path to audio_input for improved consistency and clarity. The refactoring reflects that these parameters can accept both file paths (strings) and raw audio bytes.
Key changes:
- Renamed
audio_pathtoaudio_inputinBaseASRand all ASR subclasses (BcutASR, JianYingASR, FasterWhisperASR, WhisperAPI, WhisperCppASR) - Updated all test files to use the new parameter name
- Added a newly created test file for HearASR (test_hear_asr.py)
- Removed UI text indicating Whisper CPP is "unstable"
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/core/asr/base.py | Renamed parameter from audio_path to audio_input in BaseASR class and updated related references |
| app/core/asr/bcut.py | Updated BcutASR constructor to use audio_input parameter |
| app/core/asr/jianying.py | Updated JianYingASR constructor to use audio_input parameter |
| app/core/asr/faster_whisper.py | Updated FasterWhisperASR constructor and references to use audio_input |
| app/core/asr/whisper_api.py | Updated WhisperAPI constructor and documentation to use audio_input |
| app/core/asr/whisper_cpp.py | Updated WhisperCppASR constructor to use audio_input with improved validation logic |
| tests/test_asr/test_whisper_api_asr.py | Updated test instantiations to use audio_input parameter |
| tests/test_asr/test_jianying_asr.py | Updated test instantiations to use audio_input parameter |
| tests/test_asr/test_hear_asr.py | New test file added using old audio_path parameter name (inconsistent with refactor) |
| tests/test_asr/test_bcut_asr.py | Updated test instantiations to use audio_input parameter |
| tests/test_asr/test_chunking.py | Updated MockASR class and test instantiations to use audio_input |
| tests/test_asr/test_chunked_asr.py | Updated MockASR class and test variables to use audio_input naming |
| app/components/WhisperCppSettingWidget.py | Removed "unstable" label from Whisper CPP settings UI text |
| resource/translations/*.ts | Updated source text for Whisper CPP settings but translations not updated |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| super().__init__(audio_path, use_cache) | ||
| self.audio_path = audio_path | ||
| super().__init__(audio_input, use_cache) | ||
| self.audio_input = audio_input |
There was a problem hiding this comment.
Redundant assignment. The audio_input parameter is already assigned to self.audio_input in the parent BaseASR.__init__() method (line 50 in base.py). This duplicate assignment should be removed.
| self.audio_input = audio_input |
| <location filename="../../app/components/WhisperCppSettingWidget.py" line="530"/> | ||
| <source>Whisper CPP 设置(不稳定 🤔)</source> | ||
| <source>Whisper CPP 设置</source> | ||
| <translation>Whisper CPP 設置(不穩定 🤔)</translation> |
There was a problem hiding this comment.
Translation mismatch. The source text was updated to remove the 'unstable' label, but the Traditional Chinese translation still contains '(不穩定 🤔)'. The translation should be updated to match: 'Whisper CPP 設置'.
| <translation>Whisper CPP 設置(不穩定 🤔)</translation> | |
| <translation>Whisper CPP 設置</translation> |
| <location filename="../../app/components/WhisperCppSettingWidget.py" line="530" /> | ||
| <source>Whisper CPP 设置(不稳定 🤔)</source> | ||
| <source>Whisper CPP 设置</source> | ||
| <translation>Whisper CPP Settings (unstable 🤔)</translation> |
There was a problem hiding this comment.
Translation mismatch. The source text was updated to remove the 'unstable' label, but the English translation still contains '(unstable 🤔)'. The translation should be updated to match: 'Whisper CPP Settings'.
| <translation>Whisper CPP Settings (unstable 🤔)</translation> | |
| <translation>Whisper CPP Settings</translation> |
audio_path参数重命名为audio_input,以提高一致性和可读性。这些改动增强了代码的可维护性,减少了潜在的混淆。
Note
Unifies the ASR audio input parameter to
audio_inputacross core and implementations, updates Whisper.cpp handling, refreshes UI label/translations, and adjusts/extends tests (including HearASR).audio_path->audio_inputinBaseASRand implementations (BcutASR,FasterWhisperASR,JianYingASR,WhisperAPI,WhisperCppASR).BaseASR(fallback duration0.01s).audio_input(e.g.,_build_command, temp file copies, cache keys).whisper_cpp_audio.wav; duration sourced fromself.audio_duration; relax.wavcheck for bytes input; example updated.Whisper CPP 设置; update corresponding translations (en_US,zh_CN,zh_HK).audio_inputparameter across suites.tests/test_asr/test_hear_asr.pyforHearASR(availability, command building, integration paths).Written by Cursor Bugbot for commit 26f87a0. This will update automatically on new commits. Configure here.