Skip to content

Make diarized transcription duration and task optional #802

Description

@wskr00

Bug

TranscriptionDiarized models both duration and task as required, but the diarized_json transcription response can omit both fields.

A direct response from the OpenAI API contained text, segments, and usage, but no duration or task properties.

This causes two problems:

  • TranscriptionDiarized.duration() throws OpenAIInvalidDataException: duration is not set.
  • TranscriptionDiarized.validate() fails because an absent task does not match the expected transcribe value.

Reproduction

Audio file: https://github.com/openai/whisper/blob/main/tests/jfk.flac

A direct request to the OpenAI audio transcriptions endpoint with response_format=diarized_json returned:

{
    "text": "And so my fellow Americans, ask not what your country can do for you, ask what you can do for your country.",
    "segments": [
        {
            "type": "transcript.text.segment",
            "text": " And so my fellow Americans, ask not what your country can do for you,",
            "speaker": "A",
            "start": 0.0,
            "end": 7.499999999999999,
            "id": "seg_0"
        },
        {
            "type": "transcript.text.segment",
            "text": " ask what you can do for your country.",
            "speaker": "A",
            "start": 8.15,
            "end": 10.3,
            "id": "seg_1"
        }
    ],
    "usage": {
        "type": "tokens",
        "total_tokens": 431,
        "input_tokens": 110,
        "input_token_details": {
            "text_tokens": 0,
            "audio_tokens": 110
        },
        "output_tokens": 321
    }
}

The response contains no duration nor task property.

Expected behavior

duration and task should be optional in TranscriptionDiarized, since it can be absent from a valid API response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions