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

Skip OpenAIWhisperParser extremely small audio chunks to avoid api error #11450

Merged
merged 6 commits into from
Feb 23, 2024

Conversation

leodiegues
Copy link

Description
This PR addresses a rare issue in OpenAIWhisperParser that causes it to crash when processing an audio file with a duration very close to the class's chunk size threshold of 20 minutes.

Issue
#11449

Dependencies
None

Tag maintainer
@agola11 @eyurtsev

Twitter handle
leonardodiegues

@vercel
Copy link

vercel bot commented Oct 5, 2023

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2024 7:21pm

@dosubot dosubot bot added Ɑ: doc loader Related to document loader module (not documentation) 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Oct 5, 2023
@leodiegues leodiegues changed the title Skip OpenAIWhisperParser extremely small audio chunks to avoid api … Skip OpenAIWhisperParser extremely small audio chunks to avoid api error Oct 5, 2023
@leodiegues
Copy link
Author

@agola11 @eyurtsev

@hwchase17 hwchase17 closed this Jan 30, 2024
@baskaryan baskaryan reopened this Jan 30, 2024
@baskaryan
Copy link
Collaborator

Apologies for the slow review! Pr has some merge conflicts, happy to re-review if you'd like to resolve

@leodiegues
Copy link
Author

Apologies for the slow review! Pr has some merge conflicts, happy to re-review if you'd like to resolve

No problem! Will resolve conflicts this weekend

@leodiegues leodiegues closed this Feb 17, 2024
@leodiegues leodiegues force-pushed the fix-whisper-chunk-error branch from 373456c to d7c26c8 Compare February 17, 2024 20:28
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 17, 2024
@leodiegues leodiegues reopened this Feb 17, 2024
@leodiegues
Copy link
Author

@baskaryan, I believe everything is in order now.

@@ -52,11 +52,15 @@ def lazy_parse(self, blob: Blob) -> Iterator[Document]:
# Need to meet 25MB size limit for Whisper API
chunk_duration = 20
chunk_duration_ms = chunk_duration * 60 * 1000
chunk_duration_threshold = 0.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we make this a configurable param with default value of None, so that default behavior doesn't change

Copy link
Author

Choose a reason for hiding this comment

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

Does it make sense to make this param configurable? chunk_duration_threshold only reflects OpenAI's API minimal audio duration, which is 0.1s.

Attempt 1 failed. Exception: Audio file is too short. Minimum audio length is 0.1 seconds.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah i see. perhaps still worth making configurable (with default value 0.1) for future proofing? i.e. in case OpenAI API is updated some time in the future to accept shorter lengths

Copy link
Collaborator

Choose a reason for hiding this comment

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

also could we add a comment somewhere explaining why the threshold is needed

Copy link
Author

Choose a reason for hiding this comment

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

I made the changes you suggested and thought more about the future-proofing idea – you're right about that. Also, I added the comments you mentioned to the class docstring. But if you'd rather have them inside the code, just let me know, and I'll fix it

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Feb 20, 2024
@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Feb 20, 2024
@baskaryan baskaryan merged commit b15fccb into langchain-ai:master Feb 23, 2024
58 checks passed
@leodiegues leodiegues deleted the fix-whisper-chunk-error branch February 23, 2024 18:07
al1p pushed a commit to al1p/langchain that referenced this pull request Feb 27, 2024
…unks to avoid api error (langchain-ai#11450)

**Description**
This PR addresses a rare issue in `OpenAIWhisperParser` that causes it
to crash when processing an audio file with a duration very close to the
class's chunk size threshold of 20 minutes.

**Issue**
langchain-ai#11449

**Dependencies**
None

**Tag maintainer**
@agola11 @eyurtsev 

**Twitter handle**
leonardodiegues

---------

Co-authored-by: Leonardo Diegues <[email protected]>
Co-authored-by: Bagatur <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: doc loader Related to document loader module (not documentation) lgtm PR looks good. Use to confirm that a PR is ready for merging. size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants