Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new parameter forced_decoder_ids to OpenAIWhisperParserLocal + small bug fix #8793

Merged

Conversation

idcore
Copy link
Contributor

@idcore idcore commented Aug 5, 2023

  • Description: new parameter forced_decoder_ids for OpenAIWhisperParserLocal to force input language, and enable optional translate mode. Usage example:
    processor = WhisperProcessor.from_pretrained("openai/whisper-medium")
    forced_decoder_ids = processor.get_decoder_prompt_ids(language="french", task="transcribe")
    #forced_decoder_ids = processor.get_decoder_prompt_ids(language="french", task="translate")
    loader = GenericLoader(YoutubeAudioLoader(urls, save_dir), OpenAIWhisperParserLocal(lang_model="openai/whisper-medium",forced_decoder_ids=forced_decoder_ids))
  • Issue Add option to directly set input language for OpenAIWhisperParserLocal #8792
  • Tag maintainer: @rlancemartin, @eyurtsev

Please make sure you're PR is passing linting and testing before submitting. Run make format, make lint and make test to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

@vercel
Copy link

vercel bot commented Aug 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2023 7:52am

@dosubot dosubot bot added Ɑ: doc loader Related to document loader module (not documentation) 🤖:improvement Medium size change to existing code to handle new use-cases labels Aug 5, 2023
@@ -136,10 +156,19 @@ def __init__(self, device: str = "0", lang_model: Optional[str] = None):
# load model for inference
self.pipe = pipeline(
"automatic-speech-recognition",
model="openai/whisper-medium",
model=self.lang_model, # fix to use model name that was evaluated earlier
Copy link
Contributor

Choose a reason for hiding this comment

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

i would remove this comment, it loses meaning outside of this pr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. Fixed.

chunk_length_s=30,
device=self.device,
)
try:
if forced_decoder_ids is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: i feel like its slightly nicer to do:

if ...:
    try:
    ...
    except:
    ...

dont care super strongly tho

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. Fixed.

Copy link
Contributor

@hwchase17 hwchase17 left a comment

Choose a reason for hiding this comment

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

lgtm! thanks

@hwchase17 hwchase17 added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Aug 6, 2023
@idcore
Copy link
Contributor Author

idcore commented Aug 7, 2023

Minor fix - shortened 1 line due to lint failed check. Will look into why local lint didn't displayed it for me.

@baskaryan baskaryan merged commit fe78aff into langchain-ai:master Aug 7, 2023
22 checks passed
@idcore idcore deleted the add_forced_decoder_ids_to_whisper_local branch August 12, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: doc loader Related to document loader module (not documentation) 🤖:improvement Medium size change to existing code to handle new use-cases lgtm PR looks good. Use to confirm that a PR is ready for merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants