OpenAI Whisper speech recognition API model usage | python speech recognition

In addition to ChatGPT's GPT3.5 API update, OpenAI has launched a Whisper speech recognition model. 96 languages ​​are supported.

After installing the openai library in Python, put the audio directory that needs to be translated into it, and run the program to generate the text corresponding to the audio.

import openai

openai.api_key = 'your API Key'

file = open("openai.mp3", "rb")
transcription = openai.Audio.transcribe("whisper-1", file)
translation = openai.Audio.translate("whisper-1", file)

print(transcription, translation)

that's all.

Guess you like

Origin blog.csdn.net/qq_41608408/article/details/129329820