Skip to content

Instantly share code, notes, and snippets.

@Terieyenike
Created August 21, 2024 09:26
Show Gist options
  • Select an option

  • Save Terieyenike/44670bf4f58be984d16fa9540199cc5c to your computer and use it in GitHub Desktop.

Select an option

Save Terieyenike/44670bf4f58be984d16fa9540199cc5c to your computer and use it in GitHub Desktop.
Translation with Whisper
import os
from dotenv import load_dotenv
from openai import OpenAI
client = OpenAI()
api_key = os.getenv('OPENAI_API_KEY')
file = 'audio/german.mp3'
with open(file, 'rb') as audio_file:
translation = client.audio.translations.create(
model = 'whisper-1',
file = audio_file
)
print(translation.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment