Skip to content

Auto Whisper Transcribe #30

Auto Whisper Transcribe

Auto Whisper Transcribe #30

Workflow file for this run

name: Auto Whisper Transcribe
on:
workflow_dispatch:
inputs:
youtube_link:
description: "YouTube Video URL or playlist URL"
required: true
# Allow pull request
permissions:
pull-requests: write
repository-projects: write
contents: write
jobs:
transcribe:
runs-on: ubuntu-latest
steps:
# Parse the link into just video id or playlist id
# and save it into environment variable
- name: Parse YouTube link
id: parse_youtube_link
run: |
echo "::set-output name=video_id::$(echo ${{ github.event.inputs.youtube_link }} | sed -n 's/.*\b\(v=\|list=\)\([^&]*\).*/\2/p')"
echo "::set-output name=playlist_id::$(echo ${{ github.event.inputs.youtube_link }} | sed -n 's/.*\b\(v=\|list=\)\([^&]*\).*/\2/p')"
# Check if the link is a playlist or not
- name: Check if the link is a playlist
id: check_playlist
run: |
if [ -z "${{ steps.parse_youtube_link.outputs.playlist_id }}" ]; then
echo "::set-output name=is_playlist::false"
else
echo "::set-output name=is_playlist::true"
fi
- name: Setup Python
uses: actions/setup-python@v3.1.3
- name: Install FFmpeg
run: sudo apt-get install -y ffmpeg
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
pip install pytube
pip install yt-dlp
pip install openai
- name: Run transcription script
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: python tools/auto_whisper.py "${{ github.event.inputs.youtube_link }}"
- name: Add all subtitle to be tracked
run: |
git add .
- name: Create Pull Request
if: ${{ success() }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Add transcription for video ${{ steps.parse_youtube_link.outputs.video_id }}${{ steps.parse_youtube_link.outputs.playlist_id }}"
title: "Add transcription for video ${{ steps.parse_youtube_link.outputs.video_id }}${{ steps.parse_youtube_link.outputs.playlist_id }}"
body: "This PR adds transcription for video ${{ steps.parse_youtube_link.outputs.video_id }}${{ steps.parse_youtube_link.outputs.playlist_id }}"
branch: "transcribe-${{ steps.parse_youtube_link.outputs.video_id }}${{ steps.parse_youtube_link.outputs.playlist_id }}"
base: "main"
labels: "auto-transcribe"