Skip to content

Do not encode supplied initial_prompt if it is not a string#1299

Open
jzyeezy wants to merge 4 commits into
SYSTRAN:masterfrom
jzyeezy:master
Open

Do not encode supplied initial_prompt if it is not a string#1299
jzyeezy wants to merge 4 commits into
SYSTRAN:masterfrom
jzyeezy:master

Conversation

@jzyeezy
Copy link
Copy Markdown

@jzyeezy jzyeezy commented May 15, 2025

The BatchedInferencePipeline#transcribe method technically supports passing an already encoded tokenized list as the initial_prompt. The code path should only try to encode the provided prompt if it's a string.

This fixes the bug where faster_whisper will fail due to: TypeError: TextInputSequence must be str when passing a List of integers as the initial_prompt.

Copy link
Copy Markdown
Collaborator

@MahmoudAshraf97 MahmoudAshraf97 left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, You still need to handle the case where options.initial_prompt is None

@MahmoudAshraf97
Copy link
Copy Markdown
Collaborator

Also, even if the typing hints support, Why would you use a tokenized string instead of a string? note that different whisper models use different tokenizers so the tokenized string is not generalizable
I prefer if we change the typing hint to just accept str instead

@jzyeezy
Copy link
Copy Markdown
Author

jzyeezy commented May 19, 2025

Why would you use a tokenized string instead of a string?

@MahmoudAshraf97 gotcha. I only discovered this bug while experimenting with the parameter to observe if there's any upside in providing the prompt in this format. I'm happy to update the signature of this parameter to accept only a string.

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