reel2meal / transcribe.py
jacklangerman's picture
Upload folder using huggingface_hub
f534c35 verified
raw
history blame
755 Bytes
from openai import OpenAI
import os
import argparse
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"),
# defaults to os.environ.get("OPENAI_API_KEY")
# api_key="My API Key",
)
from docx import Document
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--audio_file_path",
type=str,
required=True,
help="Path to the audio file to transcribe",
)
parser.add_argument(
"--output_file_path",
type=str,
required=True,
help="Path to the output file",
)
return parser.parse_args()
def transcribe_audio(audio_file_path):
with open(audio_file_path, 'rb') as audio_file:
transcription = client.audio.transcriptions.create("whisper-1", audio_file)
return transcription['text']