Add access to segment text as bytes #79
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Access method needed for issues related to Issue #46
Change
This change adds an additional access method to the whisper_state to allow access to the segment text as a vector of u8.
Use Case
This is used to handle cases where the segment is not a valid utf-8 string and will throw an error when using full_get_segment_text. This can be pretty common for multi utf-8 byte languages like Mandarin. The segment is not guarantied to end on the proper utf-8 boundary, but can be found in the next segment. When an error is returned from full_get_segment_text the library user can simply grab the bytes (with this new method), buffer them and add the next segment to them until a proper utf8 string is found.
Testing
All testing was done against the following random Chinese language podcast "https://anchor.fm/s/1553388c/podcast/play/60927763/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2022-10-20%2F3b2b6ec4-4399-393e-c056-06e16f5c0c9e.mp3"