Spaces:
Sleeping
Sleeping
File size: 691 Bytes
ad94a24 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import openai
import whisper
import json
def transcribe_audio(audio_file):
# Option A: local Whisper
model = whisper.load_model("base")
result = model.transcribe(audio_file)
return result["text"]
def generate_edit_instructions(transcript_text):
system_msg = """You are a video editing assistant..."""
user_msg = f"Transcript:\n{transcript_text}\n\nOutput instructions in JSON..."
# GPT-based approach
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[
{"role": "system", "content": system_msg},
{"role": "user", "content": user_msg}
],
)
return response.choices[0].message["content"]
|