Spaces:
Runtime error
Runtime error
import openai | |
from io import BytesIO | |
from engines import TranscriptEngine | |
def transcribe(engine: TranscriptEngine, language: str, audio_file: BytesIO) -> str: | |
return engine.transcribe(language, audio_file) | |
def summarize_transcript( | |
openai_api_key: str, | |
transcript: str, | |
openai_model: str = 'gpt-4', | |
prompt: str = 'Summarize the following audio transcription with a list of the key points with the speakers in the original language:', | |
) -> str: | |
"""Summarize the transcription using OpenAI's API""" | |
openai.api_key = openai_api_key | |
prompt = f'Please summarize the following audio transcription in the original language: {transcript}' | |
response = openai.ChatCompletion.create( | |
model=openai_model, | |
messages=[{'role': 'user', 'content': f'{prompt}\n\n{transcript}'}], | |
temperature=0.5, | |
max_tokens=150, | |
) | |
summary = response['choices'][0]['message']['content'] | |
return summary | |