@taskmaster4450le's thread

taskmaster4450le
81
@taskmaster4450le
·

Before we dive into the code, you need two things:

OpenAI API Key
Sample audio file
First, install the OpenAI library (Use ! only if you are installing it on the notebook):

!pip install openai
Now let’s write the code to transcribe a sample speech file to text:

#import the openai Library
from openai import OpenAI

Create an api client

client = OpenAI(api_key="YOUR_KEY_HERE")

Load audio file

audio_file= open("AUDIO_FILE_PATH", "rb")

Transcribe

transcription = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file
)

Print the transcribed text

print(transcription.text)

No replies made yet. Would you like to be the one to do so?