Skip to content

How to initiate realtime transcription session? #2253

Closed as not planned
Closed as not planned
@olarcher

Description

@olarcher

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

Support for realtime audio transcriptions was recently announced:
https://platform.openai.com/docs/guides/speech-to-text#streaming-the-transcription-of-an-ongoing-audio-recording

I noticed that in the latest release of the python sdk, an AsyncTranscriptionSessions object has become available under client.beta.realtime.transcription_sessions. However, I am not sure how to use this to initiate a new realtime transcription session. Could someone please provide an example?

To Reproduce

Instantiate a new async client with

client = AsyncOpenAI(api_key=OPENAI_API_KEY)

Not sure what to do next to start a realtime transcription session.

Tried:

 async with client.beta.realtime.connect(model="gpt-4o-realtime-preview", extra_query={"intent": "transcription"} ) as conn:
        await client.beta.realtime.transcription_sessions.create(
            input_audio_transcription={
                "model": "gpt-4o-transcribe",
                "language": "de"
            }
        )

        async for message in conn:
                print(message)

Get error:
ErrorEvent(error=Error(message='You must not provide a model parameter for transcription sessions.', type='invalid_request_error', code='invalid_model', event_id=None, param=None), event_id='event_BEbGnb8W18CQ9cEZPdORK', type='error')

Code snippets

OS

macOS

Python version

3.12

Library version

openai==1.68.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions