Skip to content

Add timestamp_granularities for AzureOpenAI #1324

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

Closed
1 task done
pourmand1376 opened this issue Apr 17, 2024 · 3 comments
Closed
1 task done

Add timestamp_granularities for AzureOpenAI #1324

pourmand1376 opened this issue Apr 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@pourmand1376
Copy link

pourmand1376 commented Apr 17, 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

TypeError: Translations.create() got an unexpected keyword argument 'timestamp_granularities'

This is when calling AzureOpenAI client with code below.

To Reproduce

To Reproduce you should use AzureOpenAI client (OpenAI client is fine):

import os
from openai import AzureOpenAI

client = AzureOpenAI(
    api_key="API_KEY",  
    api_version="2023-12-01-preview",
    azure_endpoint="ENDPOINT_URL"
)
audio_file = open("output_audio.m4a", "rb")
transcript = client.audio.translations.create(
  model="whisper-1",
  file=audio_file,
  prompt="",
  response_format="verbose_json",
  timestamp_granularities=["word"] # or segment
  
)

I've already also made a PR.

Code snippets

This code actually works without any problem:

from openai import OpenAI
client = OpenAI(api_key='OPENAPI_KEY')

audio_file = open("output_audio.m4a", "rb")
transcript = client.audio.transcriptions.create(
  file=audio_file,
  model="whisper-1",
  response_format="verbose_json",
  timestamp_granularities=["word"],
)

print(transcript.words)

But When you change OpenAI to AzureOpenAI it doesn't work.

Also this argument is supported in Azure and it works. So, it is just the matter of adding it here.

OS

MacOS, Linux

Python version

Python v3.12.1

Library version

1.20.0

@pourmand1376 pourmand1376 added the bug Something isn't working label Apr 17, 2024
@rattrayalex
Copy link
Collaborator

It looks like you may have mixed up transcriptions and translations when switching between clients? Translations don't support that param: https://platform.openai.com/docs/api-reference/audio/createTranslation

@rattrayalex rattrayalex closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2024
@pourmand1376
Copy link
Author

pourmand1376 commented Apr 18, 2024

Thank you for observing that. It is odd that as I tested translations actually supports that parameter and even gives segment level and word level results. But anyway. My Problem was from me and this is solved now.

@rattrayalex
Copy link
Collaborator

Ah – in that case, please open a PR or issue on https://github.com/openai/openai-openapi !

stainless-app bot pushed a commit that referenced this issue Mar 27, 2025
The [WebSocket spec at WHATWG](https://websockets.spec.whatwg.org/#ref-for-dom-websocket-websocket%E2%91%A0) indicates that the `url` parameter of the WebSocket constructor is a string. Some implementations (like Chrome) will accept a URL object, but calling .toString() should work for all cases.

Fixes #1323.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants