Skip to content

added support for other file formats like srt and vtt #1050

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

Closed
wants to merge 3 commits into from
Closed

added support for other file formats like srt and vtt #1050

wants to merge 3 commits into from

Conversation

HiPrabel
Copy link

@HiPrabel HiPrabel commented Jan 6, 2024

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Closes #1035
made the necessary changes to support the other file formats

  • Modified CLIAudio.transcribe to handle 'srt' and 'vtt' response formats.
  • Adjusted output formatting to accommodate SRT and VTT transcript content.

Any feedback on the changes is highly appreciated. Please review the code modifications @rattrayalex

Additional context & links

@HiPrabel HiPrabel requested a review from a team as a code owner January 6, 2024 11:36
@rattrayalex
Copy link
Collaborator

Thank you for the contribution! We'll try to take a look in the coming days.

@rattrayalex
Copy link
Collaborator

@HiPrabel looks like there are lints failing in CI

solved, check this
Copy link
Author

@HiPrabel HiPrabel left a comment

Choose a reason for hiding this comment

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

@rattrayalex
Copy link
Collaborator

Thank you!

@RobertCraigie , can you take a look?

Comment on lines +79 to +88
if args.response_format == 'json':
print_model(model)
elif args.response_format == 'srt':
# Handle SRT response format
print_model(model.get('srt'))
elif args.response_format == 'vtt':
# Handle VTT response format
print_model(model.get('vtt'))
else:
raise CLIError(f"Unsupported response format: {args.response_format}")
Copy link
Collaborator

@RobertCraigie RobertCraigie Jan 15, 2024

Choose a reason for hiding this comment

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

Looks like you've got type checking errors.

I think this isn't quite correct as well, I think it should be this instead so that we don't always have to update this for every response_format.

        model = cast(
            "str | Transcription",
            get_client().audio.transcriptions.create(
                file=(args.file, buffer_reader),
                model=args.model,
                language=args.language or NOT_GIVEN,
                temperature=args.temperature or NOT_GIVEN,
                prompt=args.prompt or NOT_GIVEN,
                # casts required because the API is typed for enums
                # but we don't want to validate that here for forwards-compat
                response_format=cast(Any, args.response_format),
            ),
        )
        if isinstance(model, str):
            sys.stdout.write("\n" + model + "\n")
        else:
            print_model(model)

And the same applies below as well (replacing Transcription with Translation)

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.

openai api audio.transcriptions.create not working when response format is not json
3 participants