corfodemo / ailib.py
sergiolucero's picture
Update ailib.py
2b4c43b verified
raw
history blame
531 Bytes
import openai
import time
def whisper_transcribe(fn, temperature=0):
t0 = time.time()
audio_file = open(fn,'rb') # redundant?
whisper = openai_client.audio.transcriptions.create
transcript = whisper(model=OPENAI_TRANSCRIPTION_MODEL,
file=audio_file, language='es',
temperature=temperature) # to do, explore temperature
dt = round(time.time()-t0,2)
transcript = transcript.text
print(f'Whisper transcribe [dt={dt} secs]')
return transcript