Spaces:
Build error
Build error
import gradio as gr | |
import openai | |
import os | |
from io import BytesIO | |
import tempfile | |
def create_meeting_summary(openai_key, prompt, uploaded_audio): | |
openai.api_key = openai_key | |
transcript = openai.Audio.transcribe("whisper-1", open(uploaded_audio, "rb"), response_format="verbose_json") | |
transcript_text = "" | |
for segment in transcript.segments: | |
transcript_text += f"{segment['text']}\n" | |
''' | |
system_template = """会議の文字起こしが渡されます。 | |
この会議のサマリーをMarkdown形式で作成してください。サマリーは、以下のような形式で書いてください。 | |
- 会議の目的 | |
- 会議の内容 | |
- 会議の結果""" | |
''' | |
system_template = prompt | |
completion = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[ | |
{"role": "system", "content": system_template}, | |
{"role": "user", "content": transcript_text} | |
] | |
) | |
summary = completion.choices[0].message.content | |
return summary, transcript_text | |
inputs = [ | |
gr.Textbox(lines=1, label="openai_key", type="password"), | |
gr.TextArea(label="プロンプト", value="""会議の文字起こしが渡されます。 | |
この会議のサマリーをMarkdown形式で作成してください。サマリーは、以下のような形式で書いてください。 | |
- 会議の目的 | |
- 会議の内容 | |
- 会議の結果"""), | |
gr.Audio(type="filepath", label="音声ファイルをアップロード") | |
] | |
outputs = [ | |
gr.Textbox(label="会議サマリー"), | |
gr.Textbox(label="文字起こし") | |
] | |
app = gr.Interface( | |
fn=create_meeting_summary, | |
inputs=inputs, | |
outputs=outputs, | |
title="会議サマリー生成アプリ", | |
description="音声ファイルをアップロードして、会議のサマリーをMarkdown形式で作成します。" | |
) | |
app.launch(debug=True) |