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

update: Ensure method _asdict also converts Word object into a native dict #667

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

klebster2
Copy link

@klebster2 klebster2 commented Feb 2, 2024

Currently, after segments are generated with the WhiperModel.transcribe() method and word_timestamps=True, upon using method Segment()._asdict, we get output like the following:

example_of_word_issue

In the image above, the upper red box is undesired, because _asdict should convert to native types. Additionally, this causes information, such as the dictionary keys are also lost when we convert the object that is supposedly a dict using json.dumps as exemplified in the lower red box.

The change presented therefore ensures that all Word() objects are first converted to native types, so that the keys for each Word() are retained when the _asdict method is called, or json.dumps(segment._asdict()) is called.

example_of_word_fix

@klebster2 klebster2 changed the title update: Ensure the NamedTuple method also works to turn Word into dict update: Ensure the method _asdict also turns a Word into a dict Feb 2, 2024
@klebster2 klebster2 changed the title update: Ensure the method _asdict also turns a Word into a dict update: Ensure the method _asdict also converts Word object into a native dict Feb 2, 2024
@klebster2 klebster2 changed the title update: Ensure the method _asdict also converts Word object into a native dict update: Ensure method _asdict also converts Word object into a native dict Feb 2, 2024
@klebster2 klebster2 marked this pull request as ready for review February 2, 2024 21:22
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.

None yet

1 participant