OpenAI Whisper API with Python latest tutorial | How to convert mp3 audio to text AI example

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone in this video I'll be showing you how  to use whisper API from openAI which converts our   audio files into text with python so let's get  started so the prerequisites for this video are   going to be you must have python installed in  your system and also you must have an open AI   or chatGPT account and if you want to know how to  install python you can click on the card that is   appearing on top so once you done with this  let's just open Visual Studio code or your   favorite editor so I opened Visual Studio code I'm  having here an empty folder and inside that folder   you need to create a dot py file so just click  this and let me just name it as main.py so at   first before coding we need to install the open  AI Library so for doing that just go to search   and type command prompt Zoom it you need to run  the command pip install open AI so by this way we   will be able to install open AI Library so once  you're done with this just locate the audio file   which you want to convert to text so I'm just  going to just copy paste my audio file into the   main folder in which I have my dot py file and  here I'm having my audio file let me just drag   and drop this here so I'm having my audio file  4 5 6 I'm just saying the numbers in English   this is my audio so now let's begin to code so  first thing is going to be the import as usual   we will be importing the open AI Library which  we had installed earlier and next is going to be   the open AI API key which is super important so  it's going to be openAI DOT we'll be having the   API key over here and we need to paste the openAI  API key inside this so for getting the key what   you need to do is you need to just Google open  AI and you need to click on the first link and   here you need to have an account so I'm already  having an account so I'll just click on login and   here you'll be having three options we need to  click on API and we need to click on our profile   and we need to go to view API keys and here  we'll be having option to create a new secret   API key so just select this and click on create  secret key it will ask you to complete a puzzle   just do this so the verification is complete  and next we will be getting the key just copy   this don't forget to copy this and never share  this key to anyone so I'm done copying I just   click on done over here so this is fine and next  let me go to the code and I'll just paste my key   over here so it needs to come within this double  quotes so once we're done with this next we need   to specify our audio path so I'll just go here and  type audio path equal to and since I'm having my   audio in the same folder I'm not going to use  this dot slash the whole path I'm not going to   give the whole path like that since I'm having it  within my main folder I'm just going to directly   give the audio file name which is aud. MP3  and you need to give it with the extension   okay don't forget the extension and next is we  will be using the open function so it's going   to be audio file I'll create another variable  equal to open and here we need to specify the   path audio path and we are going to open this  particular audio file in read mode we are not   going to make any changes or modifications we're  just going to read it so it's read mode RB yeah   you'll be getting this and next we'll be getting  the response so from the API openai's whisper API   so I'll have it as response equal to openAI dot  audio dot transcribe and here we need to pass the   open AI model name so it's going to be whisper  hyphen 1 comma and the next parameter is going   to be our audio file name which is going to be  audio file that's it and in the next line just   print the response this is going to be the text  that we'll be getting from openai's API so we   are sending our audio file and this audio file is  going to then hit the openai server and the model   is going to convert our audio file into a text  file and we are getting the response and we then   just printing the text response in the console  that's it so I'll just save it we are good now   and click on Terminal New terminal and make sure  that your terminal is opened in this path within   the folder so for running it it's going to be  python space your file name with extension and hit enter so here you can see this is a key and this  is the thing that I had said in my audio file so   if I just go and play in my audio file 7 8 9 10  so literally I I'm just saying the numbers so   I'm we are getting the direct text format of that  audio and in case if you want to directly access   the text you can just have here response do text  that's it so this will directly give you the text conversion yeah here you see right no key  Direct Value and in case if you want to   learn more about this what you can do is you  can just go to the same page same keys and here   will be having this API reference thing just  select that and to the left you'll be having   introduction authentication you'll be having  for chat audio so here you'll be having the   transcription and the translation for our audio  also we'll be having a nodejs and python so you   can just check this out also that's totally up  to you so I hope you would have found this video   useful do check the playlist of my channel  I have done a lot of videos in programming   as well as AI related content as well check  them out subscribe me thanks for watching
Info
Channel: United Top Tech
Views: 1,479
Rating: undefined out of 5
Keywords: openai whisper python, openai whisper python example, openai whisper tutorial python, whisper api python tutorial, openai whisper api, convert audio to text in python
Id: ooXF9iKFSG8
Channel Id: undefined
Length: 6min 0sec (360 seconds)
Published: Sun Oct 08 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.