Spaces:
Sleeping
Sleeping
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 | |