From the course: OpenAI API for Python Developers

Whisper Audio API: Translate audio sample

From the course: OpenAI API for Python Developers

Whisper Audio API: Translate audio sample

- [Instructor] So the next and last demonstration that we want to make is to allow to transcribe, but also to translate a document. So an audio sample, which is a foreign language. So no one in your team speaks German or French. So what we're going to ask to Whisper audio is to process the task to transcribe, but also to translate from the audio sample. So we're going to do that with right here, Whisper audio again. So you'll see that you've got this function which is already defined, and the process is going to be very simple. Basically what we do is to copy from line 26 to 40 and paste right here. And this is very simple because we just need to specify here a target language. And that's going to be only actually language. And I'm going to replace this with English, EN for English, and that's it. Alright, so we're going to run this and we're going to use also this function safe file because we would like to keep a written version of every transcript. So that's going to be saved in a transcriptions folder that we are about to create. So that's going to be done on the fly. Let's go back to the user interface. So we're going to keep this one as an original transcript. So we're not going to be putting this away. So let's actually just replace this with original transcript. That's going to become original transcript. So we'll be able to read the original transcript of the audio sample, all right? And right below we're going to add, so let's actually add to the scope, this new function, speech to translation and save file. And next, right below we're going to add another transcript, which will be translated transcript, speech to translation. And with that we're going to add a divider. So that's going to be this and then this one, like this. And we're going to allow to read the original transcript and write below the transcript in English like this. And for that, I'm just going to choose another color. This will be great. And the last step, so right below right here, we're going to add, that's going to be done also on top of that. So we're going to save the original transcripts and transcriptions. I'm going to use actually uploaded file name so we can make them match. So that's going to be upload file, name. And for the translated version, we're going to also save it on a file. And I'm going to add here, translated. All right, so let's try that. Let's make a demonstration. So my app is already up and running. And let's make a test with the French audio sample. We're going to click submit. So let's see the results. So we've got the original transcription, so- - [French Text Reader] Notre experience avec le connectique-cote. - [Instructor] And then below, right below you've got the translated versions. "Our experience with Connecticut was only positive." And you can also listen to the original audio sample. All right? So we're going to make a few changes. Let's just check also that we have properly here. So we have saved the original transcript French, which is the English one translated and the original one in French, excellent. So let's run another example with the German audio sample this time. And I think that we were missing a few things. So first I'd like to change the title here. So that's going to be now a demonstration about audio transcriptions, but also about translations. Let's just add this at the top. And I think that we're missing the color, so let's see if we can actually fix this. Okay, so that should be working now. Okay, so let's run another example. So I'm just going to refresh. So let's try now with the German audio sample. I'm going to click submit. Here we go. So you've got both results. So the original transcript and the one translated in English. Alright, so let's also listen to the audio to make sure that this is- - [German Text Reader] Unsere Erfahrung mit Connectikert war durchweg- - [Instructor] okay. So this is working just perfect. And if we go back, we'll see that we have here the transcriptions copies. And this is perfect. This was a nice example with the audio Whisper API. Audio Whisper repair can be very useful for any task requiring transcriptions and translations. For example, let's say that you want to organize a meeting, but not everyone is able to attend. At the end of the meeting, you're going to send a link to the recording, plus you could give access to a transcription. And for everyone's convenience, you also give access to a summary to allow participants to save on precious time because you also have in mind everyone's busy schedule. So that would be a nice project example for a business use case that you could easily put together with the integration of both the GPT models and Whisper audio.

Contents