Skip to content
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

Fix return type from openaiAPI.audio.transcriptions.create to include string #221

Closed
wants to merge 1 commit into from

Conversation

tadeegan
Copy link

@tadeegan tadeegan commented Aug 17, 2023

Depending on the response_format, the output can either be a json block that is represented by the Transcription interface or a string. For example if you use response_format: vtt

Repro:

// transcribe.ts
import { ClientOptions, OpenAI } from 'openai';
const OPEN_AI_CONFIG: ClientOptions = {
  apiKey: process.env.OPENAI_API_KEY,
  organization: process.env.OPENAI_ORGANIZATION_ID,
};

const openaiAPI = new OpenAI(OPEN_AI_CONFIG);

async function main() {
  const params: OpenAI.Audio.Transcriptions.TranscriptionCreateParams = {
      file: fs.createReadStream('/tmp/intput.mp4'),
      model: 'whisper-1',
      response_format: 'vtt',
      language: 'en',
  }
  const response = await openaiAPI.audio.transcriptions.create(
      params,
  );
  console.log(typeof response);
  console.log(response);
}
await main();

Outputs:

string
00:17:24.220 --> 00:17:30.780
Do you have any questions specifically on anything? I don't think so. The only thing I was gonna let
...

Depending on the response_format, the output can either be a json block that is represented by the Transcription interface or a string. For example if you use response_format: vtt
@rattrayalex
Copy link
Collaborator

Thanks for reporting this, and for the PR! We'll likely want to fix this in a different way, but I'll leave this PR open for the time being.

@tadeegan
Copy link
Author

Okay, no prob. I noticed that this is also documented incorrectly on the HTTP api docs.

@rattrayalex
Copy link
Collaborator

I've opened openai/openai-openapi#84 as draft, which would result in this change being delivered, but we'd rather not ship this until we're able to do it with an overload since it'd regress the default integration path (users whose code was previously working would need to add a typecast). Unfortunately, the way our code generation works doesn't make it trivial to add this overload manually.

Accordingly, I'm going to close this for now, but I appreciate the contribution and we do hope to get a nice fix out for this in the coming months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants