Skip to content

feat(whisper): Enhance model selection with benchmarking and resource detection#459

Open
Yogesh-333 wants to merge 7 commits into
mainfrom
whisper-model-suggestions
Open

feat(whisper): Enhance model selection with benchmarking and resource detection#459
Yogesh-333 wants to merge 7 commits into
mainfrom
whisper-model-suggestions

Conversation

@Yogesh-333

@Yogesh-333 Yogesh-333 commented Mar 12, 2025

Copy link
Copy Markdown

Description:

Enhancements to the Whisper model selection process, providing users with more informed choices based on their system's capabilities and measured model performance.

Changes:

  • Benchmarking:
    • Implemented a benchmarking feature to measure the performance of different Whisper models on the user's system.
    • The results are stored in app_settings.editable_settings under the WHISPER_PERFORMANCE_TEST_RESULTS key, keyed by the current model name.
    • This allows tracking model performance over time and providing relevant suggestions.
  • System Resource Detection:
    • Added system resource detection to dynamically categorize Whisper models.
    • This enables the application to recommend models that are best suited to the user's hardware, improving performance and user experience.
  • Fallback Mechanism:
    • Introduced a fallback mechanism for system resource detection.
    • In cases where detection fails, the application will provide default model recommendations.
  • User Experience:
    • Enhanced the user experience by providing clear and informative model recommendations based on benchmark results and detected system resources.
  • Model Performance Alert:
    • Added a message box that alerts the user when the current model's performance is not optimal, suggesting alternative models.

image

image

Summary by Sourcery

Enhance the Whisper model selection process by providing users with informed choices based on system capabilities and measured model performance. This includes benchmarking models, detecting system resources, and providing model recommendations.

New Features:

  • Implement a benchmarking feature to measure the performance of different Whisper models and store the results.
  • Add system resource detection to dynamically categorize Whisper models and recommend models best suited to the user's hardware.
  • Introduce a fallback mechanism for system resource detection to provide default model recommendations when detection fails.
  • Add a message box that alerts the user when the current model's performance is not optimal, suggesting alternative models.
  • Enhance the user experience by providing clear and informative model recommendations based on benchmark results and detected system resources.

… detection

This commit enhances the Whisper model selection process by introducing benchmarking and system resource detection:

- Implements a benchmarking feature to measure the performance of different Whisper models on the user's system, storing the results in `app_settings.editable_settings` for future suggestions.
- Uses system resource detection to dynamically categorize Whisper models, providing tailored recommendations based on the user's hardware.
- Adds a fallback mechanism for system resource detection, ensuring robust model suggestions even when detection fails.
- Improves the user experience by recommending optimal models based on benchmark results and detected system resources.
- Stored Benchmark result to avoid testing all the time.
@sourcery-ai

sourcery-ai Bot commented Mar 12, 2025

Copy link
Copy Markdown

Reviewer's Guide by Sourcery

This pull request enhances the Whisper model selection process by implementing benchmarking and system resource detection. It provides users with more informed choices based on their system's capabilities and measured model performance. A fallback mechanism is included for cases where system resource detection fails. A message box alerts the user when the current model's performance is not optimal, suggesting alternative models.

Sequence diagram for Whisper model benchmarking

sequenceDiagram
    participant User
    participant Client
    participant SettingsWindowUI
    participant app_settings
    participant faster_whisper

    User->>Client: Selects a Whisper model in settings
    Client->>SettingsWindowUI: Updates the selected model
    Client->>Client: Loads STT model
    Client->>Client: Calls benchmark_model()
    Client->>app_settings: Retrieves current model
    alt Test results exist
        app_settings->>Client: Retrieves test results
        Client->>Client: Checks if last time taken >= 10 seconds
        alt Time taken is not optimal
            Client->>User: Shows Model Performance Alert
        end
    else Test results do not exist
        Client->>faster_whisper: Transcribes test audio
        faster_whisper-->>Client: Returns transcription time
        Client->>app_settings: Stores transcription time
        Client->>Client: Checks if time taken >= 10 seconds
         alt Time taken is not optimal
            Client->>User: Shows Model Performance Alert
        end
    end
Loading

File-Level Changes

Change Details Files
Implemented dynamic Whisper model selection based on system resources.
  • Added functions to detect system RAM and VRAM.
  • Created logic to recommend Whisper models based on available system resources.
  • Updated the Whisper model dropdown in settings to display recommendations.
  • Added a mapping to store the actual model value, not the display text.
src/FreeScribe.client/UI/SettingsWindowUI.py
Added benchmarking functionality to measure Whisper model performance.
  • Implemented a function to benchmark the currently selected Whisper model.
  • Stored benchmark results in application settings.
  • Added a message box to alert the user when the current model's performance is not optimal.
src/FreeScribe.client/client.py
src/FreeScribe.client/UI/SettingsConstant.py
src/FreeScribe.client/UI/SettingsWindow.py
Added psutil and GPUtil to requirements files.
  • Added psutil to client_requirements.txt.
  • Added GPUtil to client_requirements.txt.
  • Added psutil to client_requirements_nvidia.txt.
  • Added GPUtil to client_requirements_nvidia.txt.
client_requirements.txt
client_requirements_nvidia.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey @Yogesh-333 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a unit test for the get_system_memory_info function to ensure it returns reasonable values across different platforms.
  • The benchmark_model function directly accesses and modifies app_settings.editable_settings; consider using a more structured approach for managing application settings.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/FreeScribe.client/client.py
Comment thread src/FreeScribe.client/UI/SettingsWindowUI.py Outdated
Comment thread src/FreeScribe.client/UI/SettingsWindowUI.py Outdated
@socket-security

socket-security Bot commented Mar 12, 2025

Copy link
Copy Markdown

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
pypi/gputil@1.4.0 environment, shell 0 20.3 kB anderskm

🚮 Removed packages: pypi/pydantic-core@2.23.4

View full report↗︎

This commit addresses two code quality issues:

- Replaces a bare `except:` block with `except Exception as e:` in the GPU detection code. This improves exception handling by catching specific exceptions and logging error messages for debugging.
- Replaces string concatenation with an f-string in the model selection code. This improves code readability and follows Python best practices for string formatting.
Comment thread src/FreeScribe.client/client.py
Comment thread src/FreeScribe.client/UI/SettingsWindowUI.py Outdated
Comment thread src/FreeScribe.client/UI/SettingsWindowUI.py Outdated
Comment thread src/FreeScribe.client/UI/SettingsWindowUI.py Outdated
Comment thread src/FreeScribe.client/UI/SettingsWindowUI.py Outdated
Comment thread src/FreeScribe.client/UI/SettingsWindowUI.py Outdated
@ItsSimko

Copy link
Copy Markdown
Collaborator

Feel free to discuss or disagree with any of my comments

@ItsSimko

ItsSimko commented Mar 14, 2025

Copy link
Copy Markdown
Collaborator

Do we maybe want to merge this into dev @yingbull? Since the current version should be stable. We can get this along with some of Xuns stuff and mac compatibility in dev. and then I think we can make a test build off of dev branch with out affect main code.

Yogesh-333 and others added 5 commits March 14, 2025 12:27
This commit introduces several improvements to the Whisper model handling:

- Splits `get_system_memory_info` into `get_system_memory` and `get_system_vram` functions, allowing for independent retrieval of RAM and VRAM information. In a seperate system_utils file.
- Creates a `WhisperModelEnum` class to represent Whisper models and their attributes, enhancing code organization and readability.
- Updates `generate_whisper_model_list` to utilize the `WhisperModelEnum` class, making the code more structured and maintainable.
- Modified `update_whisper_model` to clean the new model value by removing any spaces and indicators.
@Yogesh-333

Copy link
Copy Markdown
Author

@yingbull Resolved the conflicts

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