Skip to content

Add configurable Whisper decoding options to parallel diarization#362

Open
Alexandrsv wants to merge 2 commits into
MahmoudAshraf97:mainfrom
Alexandrsv:qol-whisper-parallel-options
Open

Add configurable Whisper decoding options to parallel diarization#362
Alexandrsv wants to merge 2 commits into
MahmoudAshraf97:mainfrom
Alexandrsv:qol-whisper-parallel-options

Conversation

@Alexandrsv

Copy link
Copy Markdown

This PR adds CLI options for Whisper decoding in diarize_parallel.py.

These parameters are needed for tuning and improving transcription quality, while keeping the existing parallel diarization pipeline unchanged.

It also adds the local virtualenv directory to .gitignore.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the parallel diarization pipeline by introducing configurable Whisper decoding options. These new parameters provide greater flexibility for users to tune and optimize transcription quality without altering the core diarization logic. Additionally, it improves repository hygiene by ensuring virtual environment files are ignored.

Highlights

  • Configurable Whisper Decoding Options: Added several command-line interface (CLI) options to diarize_parallel.py for fine-tuning Whisper decoding parameters such as beam size, best-of candidates, patience, compression ratio threshold, log probability threshold, condition on previous text, and temperature.
  • Virtual Environment Exclusion: Included the venv directory in .gitignore to prevent virtual environment files from being tracked by version control.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .gitignore
    • Added 'venv' to the list of ignored files.
  • diarize_parallel.py
    • Introduced new argparse arguments for 'beam-size', 'best-of', 'patience', 'compression-ratio-threshold', 'log-prob-threshold', 'condition-on-previous-text', and 'temperature'.
    • Refactored the transcribe method calls to pass the newly added decoding options using a transcribe_kwargs dictionary.
Activity
  • No human activity has occurred on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces configurable Whisper decoding options to diarize_parallel.py, which is a valuable addition for tuning transcription quality. The changes are well-structured, using a dictionary to pass the new options, which keeps the code clean. My review includes a few suggestions for improvement: using an argument group for the new CLI options to enhance readability, modifying the .gitignore entry to be more specific, and extending the temperature argument to support multiple values for temperature fallback, a feature supported by faster-whisper.

Comment thread .gitignore
*.mp3
*.m4a

venv No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To be more specific and avoid accidentally ignoring a file named venv, it's a good practice to add a trailing slash to directory entries in .gitignore.

venv/

Comment thread diarize_parallel.py
Comment on lines +96 to +144
parser.add_argument(
"--beam-size",
type=int,
default=5,
help="Beam size for Whisper decoding.",
)

parser.add_argument(
"--best-of",
type=int,
default=5,
help="Number of candidates considered during Whisper decoding.",
)

parser.add_argument(
"--patience",
type=float,
default=2.0,
help="Beam search patience for Whisper decoding.",
)

parser.add_argument(
"--compression-ratio-threshold",
type=float,
default=2.4,
help="Threshold used to reject repetitive Whisper outputs.",
)

parser.add_argument(
"--log-prob-threshold",
type=float,
default=-1.0,
help="Threshold used to reject low-confidence Whisper outputs.",
)

parser.add_argument(
"--condition-on-previous-text",
action=argparse.BooleanOptionalAction,
default=False,
help="Condition Whisper decoding on the previous segment text.",
)

parser.add_argument(
"--temperature",
type=float,
default=0.0,
help="Sampling temperature for Whisper decoding.",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To improve readability and organization, consider grouping all these new Whisper decoding options under a specific argument group.

Additionally, faster-whisper supports a tuple of temperatures for fallback. You can enable this by allowing multiple values for the --temperature argument using nargs='+'. A corresponding change will be needed where this argument is used.

    decoding_options = parser.add_argument_group("Whisper decoding options")
    decoding_options.add_argument(
        "--beam-size",
        type=int,
        default=5,
        help="Beam size for Whisper decoding.",
    )

    decoding_options.add_argument(
        "--best-of",
        type=int,
        default=5,
        help="Number of candidates considered during Whisper decoding.",
    )

    decoding_options.add_argument(
        "--patience",
        type=float,
        default=2.0,
        help="Beam search patience for Whisper decoding.",
    )

    decoding_options.add_argument(
        "--compression-ratio-threshold",
        type=float,
        default=2.4,
        help="Threshold used to reject repetitive Whisper outputs.",
    )

    decoding_options.add_argument(
        "--log-prob-threshold",
        type=float,
        default=-1.0,
        help="Threshold used to reject low-confidence Whisper outputs.",
    )

    decoding_options.add_argument(
        "--condition-on-previous-text",
        action=argparse.BooleanOptionalAction,
        default=False,
        help="Condition Whisper decoding on the previous segment text.",
    )

    decoding_options.add_argument(
        "--temperature",
        type=float,
        nargs="+",
        default=[0.0],
        help="Sampling temperature for Whisper decoding. Can be a single value or a space-separated list of values for temperature fallback.",
    )

Comment thread diarize_parallel.py
"compression_ratio_threshold": args.compression_ratio_threshold,
"log_prob_threshold": args.log_prob_threshold,
"condition_on_previous_text": args.condition_on_previous_text,
"temperature": args.temperature,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To correctly handle the list of temperatures from argparse (as suggested in another comment), you should convert it to a tuple if it contains multiple values, or extract the single float value. The transcribe function expects a float or a tuple for the temperature argument.

        "temperature": tuple(args.temperature) if len(args.temperature) > 1 else args.temperature[0],

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.

1 participant