AI
2023/06/05
飯沼 佑太

【AIツール活用】セミナー動画からイベントレポートを自動で作成するツールを実装してみた

40856_negate.png

今回、3つのAIツールを使用してセミナー動画からイベントレポートを作成するRPAツールを実装しました。具体的には、Whisperでセミナー動画の音声をテキスト化し、ChatGPTとDeepLを使ってイベントレポートを作成しました。この記事では、各ツールの詳しい使い方や、実装時の工夫点など紹介します。

動画を音声ファイルに変換

まず、対象の動画をPythonを使用して音声変換していきます。Whisperは動画と音声両方に対応していますが、動画だと文字起こしする処理に時間がかかるため、その前処理としてPythonで動画から音声を抽出して使用します。今回はwovファイルをmp3に変換しました。下記が使用したコードになります。


import ffmpeg 

# 動画を読み込み
stream = ffmpeg.input("target_video.mov")

# 出力形式の指定
stream = ffmpeg.output(stream, "target_sound.mp3")

# 実行
ffmpeg.run(stream)

Whisper APIで音声を文字起こし

次に、変換した音声からWhisper APIを使って文字起こしをしていきます。下記コードを使用することで、音声を文字起こしした内容をテキストファイルに保存することができます。


import openai 

# APIキーの設定
openai.api_key = ''
openai.organization = ''

audio_file= open('target_audio.mp3', "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file, language='ja', response_format='text')
f = open('audio_to_text.txt', 'w')
f.write(transcript)
f.close()

テキストを分割し、DeepLで英訳

次に、テキストファイルを分割します。今回のセミナー動画は30分もあり、文字数が非常に多くなりました。ChatGPTのトークン数の上限を回避するため、「イントロ」「メイン」「アウトロ」に目視で分割しました。この際、内容を理解して分割せず、キーフレーズで分割基準を判断しました。また、今回のイベントレポートの作成にあたり、ChatGPTに細かい条件を設定するプロンプトを投げる必要がありました。ChatGPTは日本語だと文字数でトークン数の算出を行うのに対し、英語だと単語数でトークン数の算出を行います。そのため、同じ容量の文章でも英語の方がトークン数を節約できます。従って、今回は文字起こししたテキストとChatGPTに投げるプロンプトを英訳することで、トークン数の節約を行いました。

英訳したテキストとプロンプトをChatGPT(GPT-4)で実行

今回、テキスト文の長さとプロンプトの細かさからGPT-4を使用しました。下記がプロンプトの例です。


# premise 
This text is a transcription of an audio recording of a technical seminar. I would like to create event report about this seminar. This text is a document about a case study. # Order From this text, create a section corresponding to the introduction of the event report to be created, according to the following output rules.

# Output Rule
・The first person in the event report must always be you
・Please create a explanatory text of level of detail that will allow those who were unable to attend this event to read this event report and have the same level of understanding as the attendees.
・Please describe the contents of this text in as much detail and specificity as possible.
・This is an event report to be created after the event, so please describe it in the past tense
・Please output this text in blocks by main points, with a set of headings and explanatory text.
・The explanatory text in the output must be least 1,000 words
・Output of intro or outro , such as preface and summary, is not needed.
・Please state only what is written in this sentence. In other words, do not describe your impressions, consideration or imagined opinions.
・Please be aware of the connection and context of each block description. Although the blocks are divided, we would like them to be in a series.
・Describe the background, assumptions, customer wishes, and challenges, and describe step-by-step, sequentially, how you responded to the challenges and what the results were.

最後に、これらのプロンプトの実行結果を再度DeepLを使用して日本語翻訳しました。こうすることで、トークン節約しながら日本語のイベントレポートを作成しました。

まとめ

今回、Whisper、DeepL、ChatGPTを使って、セミナー動画からイベントレポートを作成するRPAツールを作成しました。この他にも、議事録や説明会など様々なユースケースでの応用が可能だと考えています。皆様も是非試してみてください

New call-to-action