Skip to content

The return type hint of client.audio.transcriptions.create() is incorrect. #1633

Closed
@gbaian10

Description

@gbaian10

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

The return type hint of client.audio.transcriptions.create() is Transcription, and this type has a text attribute.

However, when the response_format is equal to text, srt, or vtt, its return value is str.
In this case, calling the text attribute will result in an error.

To Reproduce

import openai
from dotenv import load_dotenv

load_dotenv()

file_path = "example.wav"

client = openai.OpenAI()
with open(file_path, "rb") as file:
    transcript = client.audio.transcriptions.create(
        model="whisper-1", file=file, response_format="srt"
    )

    print(transcript)
    print(type(transcript))
    print(transcript.text)
    print(type(transcript.text))

OS

Windows 10

Python version

Python v3.12.4

Library version

openai v1.40.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions