Skip to content

How to return word level timestamp granularity from speech-to-text (whisper)? #440

@sohizi-entreprise

Description

@sohizi-entreprise

Hello,

I want to transcribe an audio and return word granularity timestamp. This is supported by models like Openai Whisper-1.
However, even though I passed the correct parameters to the provider, OpenRouter only return the text.

async function transcribeAudio(audioBase64: string) {
    const response = await sttCreateTranscription(openRouter, {
        sttRequest: {
            inputAudio: {
                data: audioBase64,
                format: 'mp3',
            },
            model: 'openai/whisper-1',
            provider: {
                options: {
                    openai: {
                        timestamp_granularities: ["word"],
                        response_format: "verbose_json"
                    }
                }
            }
        }
    })
    if (!response.ok) {
        throw new Error(`Failed to transcribe audio: ${response.error.message}`);
    }

    return response.value;
}

I was expecting this to return an additional key "words" as the Openai SDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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