-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Conversation
Thank you for the contribution! We'll try to take a look in the coming days. |
@HiPrabel looks like there are lints failing in CI |
solved, check this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rattrayalex done
Thank you! @RobertCraigie , can you take a look? |
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}") |
There was a problem hiding this comment.
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
)
Changes being requested
Closes #1035
made the necessary changes to support the other file formats
Any feedback on the changes is highly appreciated. Please review the code modifications @rattrayalex
Additional context & links