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

openai api audio.transcriptions.create not working when response format is not json #1035

Closed
1 task done
zzh1996 opened this issue Jan 1, 2024 · 5 comments · Fixed by #1557
Closed
1 task done
Labels
bug Something isn't working CLI good first issue Good for newcomers

Comments

@zzh1996
Copy link

zzh1996 commented Jan 1, 2024

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

If you specify --response-format to a format other than json (like srt or vtt), the openai api audio.transcriptions.create command will fail with error

To Reproduce

  1. Install openai python library version v1.6.1
  2. Prepare an audio file, such as a recording saying "hello"
  3. Run OPENAI_API_KEY=<YOUR_API_KEY> openai api audio.transcriptions.create -f 1.m4a --response-format vtt
  4. You can see the error message
Traceback (most recent call last):
  File "/usr/local/bin/openai", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/cli/_cli.py", line 129, in main
    _main()
  File "/usr/local/lib/python3.11/site-packages/openai/cli/_cli.py", line 209, in _main
    parsed.func(
  File "/usr/local/lib/python3.11/site-packages/openai/cli/_api/audio.py", line 78, in transcribe
    print_model(model)
  File "/usr/local/lib/python3.11/site-packages/openai/cli/_utils.py", line 36, in print_model
    sys.stdout.write(model_json(model, indent=2) + "\n")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_compat.py", line 125, in model_json
    return model.model_dump_json(indent=indent)
           ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'model_dump_json'

I can also reproduce this using python:3.12 Docker image.

Code snippets

No response

OS

macOS

Python version

Python 3.11.6

Library version

v1.6.1

@zzh1996 zzh1996 added the bug Something isn't working label Jan 1, 2024
@rattrayalex rattrayalex added the CLI label Jan 2, 2024
@rattrayalex
Copy link
Collaborator

rattrayalex commented Jan 2, 2024

Thanks for reporting! We would appreciate a PR from the community fixing this within the _cli folder, if anyone is able to!

Otherwise, we'll try to get to it when we can.

@rattrayalex rattrayalex added the good first issue Good for newcomers label Jan 2, 2024
zakriaalgopane added a commit to zakriaalgopane/openai-python that referenced this issue Feb 5, 2024
@nagavenkateshgavini
Copy link

@rattrayalex I would like to work on this, could you please assign this to me

@rattrayalex
Copy link
Collaborator

Go for it!

@aurishhammadhafeez
Copy link
Contributor

@rattrayalex, could you see my solution?

@RobertCraigie
Copy link
Collaborator

Thanks @aurishhammadhafeez, I've merged your PR so this will be fixed in the next release, v1.36.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI good first issue Good for newcomers
Projects
None yet
5 participants