Skip to content

Instantly share code, notes, and snippets.

@jeanmidevacc
Created January 28, 2024 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanmidevacc/2f2968ae4ca0259d7f181bcaada7f226 to your computer and use it in GitHub Desktop.
Save jeanmidevacc/2f2968ae4ca0259d7f181bcaada7f226 to your computer and use it in GitHub Desktop.
openai_whisper
from pathlib import Path
from openai import OpenAI
client_openai = OpenAI(
# This is the default and can be omitted
api_key="sk-XXX",
)
def get_transcript_openai_api(file, language="fr"):
# f = open(file, "rb")
transcript = client_openai.audio.transcriptions.create(
model="whisper-1",
language=language,
temperature=0,
file=Path(file)
)
return transcript.text
transcript = get_transcript_openai_api(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment