From 52566dc70b460637bdf362d2f97cc8a97608f0ae Mon Sep 17 00:00:00 2001 From: Prabel Date: Sat, 6 Jan 2024 16:43:37 +0530 Subject: [PATCH 1/2] added support for other file formats like srt and vtt --- src/openai/cli/_api/audio.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/openai/cli/_api/audio.py b/src/openai/cli/_api/audio.py index 90d21b9932..3a815254ec 100644 --- a/src/openai/cli/_api/audio.py +++ b/src/openai/cli/_api/audio.py @@ -75,7 +75,18 @@ def transcribe(args: CLITranscribeArgs) -> None: # but we don't want to validate that here for forwards-compat response_format=cast(Any, args.response_format), ) - print_model(model) + + if args.response_format == 'json': + print_model(model) + elif args.response_format == 'srt': + # Handle SRT response format + print(model.get('srt')) + elif args.response_format == 'vtt': + # Handle VTT response format + print(model.get('vtt')) + else: + raise CLIError(f"Unsupported response format: {args.response_format}") + @staticmethod def translate(args: CLITranslationArgs) -> None: @@ -91,4 +102,14 @@ def translate(args: CLITranslationArgs) -> None: # but we don't want to validate that here for forwards-compat response_format=cast(Any, args.response_format), ) - print_model(model) + + if args.response_format == 'json': + print_model(model) + elif args.response_format == 'srt': + # Handle SRT response format + print(model.get('srt')) + elif args.response_format == 'vtt': + # Handle VTT response format + print(model.get('vtt')) + else: + raise CLIError(f"Unsupported response format: {args.response_format}") From af50a76a4bec7eeb1c3d187aced0f6b5f2e3cb95 Mon Sep 17 00:00:00 2001 From: Prabel <120583804+HiPrabel@users.noreply.github.com> Date: Sat, 13 Jan 2024 13:34:43 +0530 Subject: [PATCH 2/2] Update audio.py solved, check this --- src/openai/cli/_api/audio.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openai/cli/_api/audio.py b/src/openai/cli/_api/audio.py index 3a815254ec..7038dfa76c 100644 --- a/src/openai/cli/_api/audio.py +++ b/src/openai/cli/_api/audio.py @@ -80,10 +80,10 @@ def transcribe(args: CLITranscribeArgs) -> None: print_model(model) elif args.response_format == 'srt': # Handle SRT response format - print(model.get('srt')) + print_model(model.get('srt')) elif args.response_format == 'vtt': # Handle VTT response format - print(model.get('vtt')) + print_model(model.get('vtt')) else: raise CLIError(f"Unsupported response format: {args.response_format}") @@ -107,9 +107,9 @@ def translate(args: CLITranslationArgs) -> None: print_model(model) elif args.response_format == 'srt': # Handle SRT response format - print(model.get('srt')) + print_model(model.get('srt')) elif args.response_format == 'vtt': # Handle VTT response format - print(model.get('vtt')) + print_model(model.get('vtt')) else: raise CLIError(f"Unsupported response format: {args.response_format}")