Skip to content

refactor: Unify audio input parameter naming#887

Merged
WEIFENG2333 merged 1 commit intomasterfrom
fix-whisper-cpp-input
Nov 22, 2025
Merged

refactor: Unify audio input parameter naming#887
WEIFENG2333 merged 1 commit intomasterfrom
fix-whisper-cpp-input

Conversation

@WEIFENG2333
Copy link
Copy Markdown
Owner

@WEIFENG2333 WEIFENG2333 commented Nov 22, 2025

  • 将多个类中的 audio_path 参数重命名为 audio_input,以提高一致性和可读性。
  • 更新相关文档和注释,确保参数说明与实际代码一致。
  • 优化音频处理逻辑,确保在不同类中对音频输入的处理方式一致。

这些改动增强了代码的可维护性,减少了潜在的混淆。


Note

Unifies the ASR audio input parameter to audio_input across core and implementations, updates Whisper.cpp handling, refreshes UI label/translations, and adjusts/extends tests (including HearASR).

  • ASR core/refactor:
    • Rename audio_path -> audio_input in BaseASR and implementations (BcutASR, FasterWhisperASR, JianYingASR, WhisperAPI, WhisperCppASR).
    • Update data loading, error messages, and duration handling in BaseASR (fallback duration 0.01s).
    • Adjust CLI builders and file handling to use audio_input (e.g., _build_command, temp file copies, cache keys).
  • Whisper.cpp:
    • Use temp filename whisper_cpp_audio.wav; duration sourced from self.audio_duration; relax .wav check for bytes input; example updated.
  • UI:
    • Change settings title text to Whisper CPP 设置; update corresponding translations (en_US, zh_CN, zh_HK).
  • Tests:
    • Update tests to use audio_input parameter across suites.
    • Add tests/test_asr/test_hear_asr.py for HearASR (availability, command building, integration paths).

Written by Cursor Bugbot for commit 26f87a0. This will update automatically on new commits. Configure here.

- 将多个类中的 `audio_path` 参数重命名为 `audio_input`,以提高一致性和可读性。
- 更新相关文档和注释,确保参数说明与实际代码一致。
- 优化音频处理逻辑,确保在不同类中对音频输入的处理方式一致。

这些改动增强了代码的可维护性,减少了潜在的混淆。
Copilot AI review requested due to automatic review settings November 22, 2025 10:30
@claude
Copy link
Copy Markdown

claude bot commented Nov 22, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@WEIFENG2333 WEIFENG2333 changed the title refactor: 统一音频输入参数命名并优化相关类 refactor: Unify audio input parameter naming Nov 22, 2025
Copy link
Copy Markdown

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 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_path to audio_input in BaseASR and 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
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
self.audio_input = audio_input

Copilot uses AI. Check for mistakes.
<location filename="../../app/components/WhisperCppSettingWidget.py" line="530"/>
<source>Whisper CPP 设置(不稳定 🤔)</source>
<source>Whisper CPP 设置</source>
<translation>Whisper CPP 設置(不穩定 🤔)</translation>
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

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

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 設置'.

Suggested change
<translation>Whisper CPP 設置(不穩定 🤔)</translation>
<translation>Whisper CPP 設置</translation>

Copilot uses AI. Check for mistakes.
<location filename="../../app/components/WhisperCppSettingWidget.py" line="530" />
<source>Whisper CPP 设置(不稳定 🤔)</source>
<source>Whisper CPP 设置</source>
<translation>Whisper CPP Settings (unstable 🤔)</translation>
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

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

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'.

Suggested change
<translation>Whisper CPP Settings (unstable 🤔)</translation>
<translation>Whisper CPP Settings</translation>

Copilot uses AI. Check for mistakes.
@WEIFENG2333 WEIFENG2333 merged commit 17118d9 into master Nov 22, 2025
8 of 9 checks passed
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