[PR #18936] feat: add VTT data transform to Document extractor #29038

Closed
opened 2026-02-21 20:44:45 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/18936

State: closed
Merged: Yes


Summary

This pull request enhances the document extraction workflow by adding support for processing WebVTT (.vtt) files. The most significant changes include introducing a new text extraction function for WebVTT files, updating MIME type and file extension handling, and adding a new dependency for WebVTT parsing.

Support for WebVTT file extraction:

  • New function for WebVTT extraction: Added _extract_text_from_vtt to handle .vtt files. The function processes captions, merges consecutive utterances by the same speaker, and formats the output in a "Speaker 'text'" style.

  • MIME type handling: Updated _extract_text_by_mime_type to include support for the text/vtt MIME type.

  • File extension handling: Modified _extract_text_by_file_extension to remove .vtt from the plain text handler and added a dedicated case for .vtt files. [1] [2]

Dependency updates:

  • Added webvtt-py dependency: Included webvtt-py~=0.5.1 in pyproject.toml to enable parsing of WebVTT files.

This was original created by @te-chan2 in https://github.com/langgenius/dify/pull/11516, however since the code base is outdated. So i recreated this PR.

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/18936 **State:** closed **Merged:** Yes --- # Summary This pull request enhances the document extraction workflow by adding support for processing WebVTT (`.vtt`) files. The most significant changes include introducing a new text extraction function for WebVTT files, updating MIME type and file extension handling, and adding a new dependency for WebVTT parsing. ### Support for WebVTT file extraction: * **New function for WebVTT extraction**: Added `_extract_text_from_vtt` to handle `.vtt` files. The function processes captions, merges consecutive utterances by the same speaker, and formats the output in a "Speaker 'text'" style. * **MIME type handling**: Updated `_extract_text_by_mime_type` to include support for the `text/vtt` MIME type. * **File extension handling**: Modified `_extract_text_by_file_extension` to remove `.vtt` from the plain text handler and added a dedicated case for `.vtt` files. [[1]](diffhunk://#diff-13ffa0868a23e512019801f778a259a440c4a88953b13a3958accda437ea0dbdR136-R145) [[2]](diffhunk://#diff-13ffa0868a23e512019801f778a259a440c4a88953b13a3958accda437ea0dbdR171-R172) ### Dependency updates: * **Added `webvtt-py` dependency**: Included `webvtt-py~=0.5.1` in `pyproject.toml` to enable parsing of WebVTT files. This was original created by @te-chan2 in https://github.com/langgenius/dify/pull/11516, however since the code base is outdated. So i recreated this PR. - close https://github.com/langgenius/dify/pull/11516 - close https://github.com/langgenius/dify/issues/11515 # Checklist > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:44:45 -05:00
yindo closed this issue 2026-02-21 20:44:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#29038