File size: 370 Bytes
6cc9795
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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