Skip to content

Instantly share code, notes, and snippets.

@shehbajdhillon
Last active October 22, 2023 05:52
Show Gist options
  • Select an option

  • Save shehbajdhillon/100755f9bbf6ecffd41c954684be5ad1 to your computer and use it in GitHub Desktop.

Select an option

Save shehbajdhillon/100755f9bbf6ecffd41c954684be5ad1 to your computer and use it in GitHub Desktop.
Transcribe Using Whisper
import os
import sys
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
def transcribe_audio(file_path):
file = open(file_path, "rb")
transcript = openai.Audio.transcribe(
model="whisper-1",
file=file,
response_format="verbose_json"
)
return transcript
def main():
file_path = sys.argv[1]
transcript = transcribe_audio(file_path=file_path)
print(transcript)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment