Execute application with Gitea Actions

This commit is contained in:
Eric Meehan 2025-03-25 22:50:55 -04:00
parent d55b346b81
commit 83779faf46
3 changed files with 37 additions and 5 deletions

View File

@ -3,3 +3,4 @@ OPENAI_BASE_URL =
OPENAI_RESPONSES_PROMPT =
SEGMENT_DURATION =
TMP_AUDIO_PATH =
TMP_VIDEO_PATH =

View File

@ -0,0 +1,22 @@
name: Execute video summary bot
on:
workflow_dispatch:
inputs:
video-url:
description: "URL for the video to be analyzed"
required: true
jobs:
Python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run applicaiton
run: python app.py

19
app.py
View File

@ -1,4 +1,3 @@
import argparse
import os
from dotenv import load_dotenv
@ -14,12 +13,24 @@ def main(args):
openai_client,
transcribe_audio(
openai_client,
get_audio_from_video(args.video_file_path)
get_audio_from_video(
get_video_from_url()
)
)
)
def get_audio_from_video(video_file_path):
def get_video_from_url():
video_file_url = os.getenv('INPUT_VIDEO_URL')
video_file_path = os.getenv('TMP_VIDEO_PATH' , '/tmp/video_summary_bot_tmp_video.mp4')
request = requests.get(video_file_url)
with open(video_file_path, 'wb') as f:
for chunk in requests.get(video_file_url).iter_content(chunk_size=255):
if chunk:
f.write(chunk)
def get_audio_from_video():
tmp_audio_path = os.getenv('TMP_AUDIO_PATH', '/tmp/video_summary_bot_tmp_audio.wav')
video_file_path = os.getenv('TMP_VIDEO_PATH')
VideoFileClip(video_file_path).audio.write_audiofile(tmp_audio_path)
return AudioSegment.from_wav(tmp_audio_path)
@ -44,6 +55,4 @@ def summarize_transcription(openai_client, transcription):
if __name__ == '__main__':
load_dotenv()
parser = argparse.ArgumentParser(description="Use AI models to summarize videos")
parser.add_argument('--video-file-path', type=str, help="Path to the video to be summarized")
main(parser.parse_args())