Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/JaiZed/subgen
Browse files Browse the repository at this point in the history
  • Loading branch information
JaiZed committed Mar 7, 2024
2 parents cbcdc20 + 175039c commit 27a3cac
Show file tree
Hide file tree
Showing 7 changed files with 400 additions and 245 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/github-actions-builddockerfile.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: Build_Subgen_Dockerfile

on:
push:
Expand All @@ -7,11 +7,35 @@ on:
paths-ignore:
- '**.md'
- '**.yml'
workflow_dispatch:

jobs:

docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set Calver Version
uses: Nelyx/[email protected]
id: setcalver
with:
default_branch: 'refs/heads/main'
format: 'YYYY.M.D'
version_prefix: ''
- name: Update version file
run: |
sed -i "s/subgen_version =.*/subgen_version = '${{ steps.setcalver.outputs.package_version }}'/" subgen/subgen.py
- name: Commit and push changes
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add subgen/subgen.py
git commit -m "Automated update subgen.py with version"
git push
-
name: Login to Docker Hub
uses: docker/[email protected]
Expand All @@ -23,12 +47,4 @@ jobs:
uses: docker/build-push-action@v5
with:
push: true
tags: mccloud/subgen:latest, mccloud/subgen:cpu
-
name: Build and push cuda
uses: docker/build-push-action@v5
with:
file: ./Dockerfile.cuda
push: true
tags: mccloud/subgen:cuda, mccloud/subgen:gpu

tags: mccloud/subgen:latest
30 changes: 24 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
FROM ubuntu:latest
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04

WORKDIR /subgen

RUN apt-get update && apt-get -y install python3 python3-pip ffmpeg
RUN apt-get update \
&& apt-get install -y \
python3 \
python3-pip \
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install \
numpy \
stable-ts \
fastapi \
requests \
faster-whisper \
uvicorn \
python-multipart \
python-ffmpeg \
whisper \
transformers \
accelerate \
optimum

ENV PYTHONUNBUFFERED 1
ENV PYTHONUNBUFFERED=1

ADD https://raw.githubusercontent.com/McCloudS/subgen/main/launcher.py /subgen/launcher.py
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/subgen/subgen.py /subgen/subgen.py

CMD [ "python3", "-u", "./subgen.py" ]

EXPOSE 8090
CMD [ "bash", "-c", "python3 -u launcher.py && python3 -u subgen.py" ]
13 changes: 0 additions & 13 deletions Dockerfile.cuda

This file was deleted.

105 changes: 56 additions & 49 deletions README.md

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@ services:
- "PLEXSERVER=http://plexserver:32400"
- "JELLYFINTOKEN=token here"
- "JELLYFINSERVER=http://jellyfin:8096"
- "WEBHOOKPORT=8090"
- "WEBHOOKPORT=9000"
- "CONCURRENT_TRANSCRIPTIONS=2"
- "WORD_LEVEL_HIGHLIGHT=False"
- "DEBUG=False"
- "DEBUG=True"
- "USE_PATH_MAPPING=False"
- "PATH_MAPPING_FROM=/tv"
- "PATH_MAPPING_TO=/Volumes/TV"
- "TRANSCRIBE_DEVICE=cpu"
- "MODEL_PATH=."
- "CLEAR_VRAM_ON_COMPLETE=True"
- "HF_TRANSFORMERS=False"
- "HF_BATCH_SIZE=24"
- "MODEL_PATH=./models"
- "UPDATE=False"
- "APPEND=False"
volumes:
- "${TV}:/tv"
- "${MOVIES}:/movies"
- "${APPDATA}/subgen/models:/subgen/models"
ports:
- "8090:8090"
- "9000:9000"
37 changes: 37 additions & 0 deletions launcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import requests

def convert_to_bool(in_bool):
if isinstance(in_bool, bool):
return in_bool
else:
value = str(in_bool).lower()
return value not in ('false', 'off', '0', 0)

def download_from_github(url, output_file):
response = requests.get(url)
if response.status_code == 200:
with open(output_file, 'wb') as f:
f.write(response.content)
print(f"File downloaded successfully to {output_file}")
else:
print(f"Failed to download file from {url}")

def main():
github_url = "https://raw.githubusercontent.com/McCloudS/subgen/main/subgen/subgen.py"
output_file = "./subgen.py"

# Check if the environment variable is set
github_download_enabled = convert_to_bool(os.getenv("UPDATE", False))

if not os.path.exists(output_file):
print(f"File {output_file} does not exist. Downloading from GitHub...")
download_from_github(github_url, output_file)
elif github_download_enabled:
print(f"File exists, but UPDATE is set to True. Downloading {output_file} from GitHub...")
download_from_github(github_url, output_file)
else:
print("Environment variable UPDATE is not set or set to False, skipping download.")

if __name__ == "__main__":
main()
Loading

0 comments on commit 27a3cac

Please sign in to comment.