From the course: OpenAI API: Speech

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Using the API in an app

Using the API in an app - OpenAI API Tutorial

From the course: OpenAI API: Speech

Using the API in an app

- [Instructor] Let's go ahead and implement our transcribe endpoint. So I'm going to navigate to 02_05_begin in the exercise files and I'll open up app.py. Now the first thing I'll want to do is check if the file exists in the request. So what I'll do is I'll add some space here and I'll say if not file in request.files and I'm going to return a message no file part in request. Now I'll also send a 400 status by typing in comma and then 400. Next, if I do have the file, I'm going to grab it by saying file equals request.files file. And I want to get it ready to send to the API, so I'll create a file_like object using BytesIO where I pass in file.read. And I want this file_like object to have a name, so I'll say that the file_like.name equals file.filename. So I grab the name of the file from the request and I append it to file_like. Now I'm ready to remove this placeholder and actually access the API by saying…

Contents