Execute application with Gitea Actions #4
@ -3,3 +3,4 @@ OPENAI_BASE_URL =
|
|||||||
OPENAI_RESPONSES_PROMPT =
|
OPENAI_RESPONSES_PROMPT =
|
||||||
SEGMENT_DURATION =
|
SEGMENT_DURATION =
|
||||||
TMP_AUDIO_PATH =
|
TMP_AUDIO_PATH =
|
||||||
|
TMP_VIDEO_PATH =
|
||||||
|
22
.gitea/workflows/execute.yaml
Normal file
22
.gitea/workflows/execute.yaml
Normal 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
19
app.py
@ -1,4 +1,3 @@
|
|||||||
import argparse
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@ -14,12 +13,24 @@ def main(args):
|
|||||||
openai_client,
|
openai_client,
|
||||||
transcribe_audio(
|
transcribe_audio(
|
||||||
openai_client,
|
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')
|
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)
|
VideoFileClip(video_file_path).audio.write_audiofile(tmp_audio_path)
|
||||||
return AudioSegment.from_wav(tmp_audio_path)
|
return AudioSegment.from_wav(tmp_audio_path)
|
||||||
|
|
||||||
@ -44,6 +55,4 @@ def summarize_transcription(openai_client, transcription):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
load_dotenv()
|
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())
|
main(parser.parse_args())
|
||||||
|
Loading…
Reference in New Issue
Block a user