hey_rehan / translation_module.py
muhammadnasar's picture
Upload 6 files
6cc9795 verified
raw
history blame contribute delete
370 Bytes
from openai import OpenAI
from dotenv import load_dotenv
import os
# Load environment variables
load_dotenv()
# Initialize OpenAI client
client = OpenAI(api_key=os.getenv("openai_api_key"))
def translation_to_english(audio_file):
transcript = client.audio.translations.create(
model="whisper-1",
file=audio_file
)
return transcript.text