Skip to content

Commit

Permalink
Language code improvements (#150)
Browse files Browse the repository at this point in the history
* Language code improvements (#147)

* improved language code handling

* expanded skipping behaviour

* remove unused code

* Added an option to detect language with whisper before choosing to skip it

---------

Co-authored-by: muisje <[email protected]>

* Default LanguageCode inputs to from_string and fix detect_langauge

* Skip detect-language if we have forced a detected language

* Typecast user inputs to ints as appropriate.

* Update subgen.py

* Update subgen.py

* Update subgen.py

---------

Co-authored-by: muisje <[email protected]>
  • Loading branch information
McCloudS and muisje committed Dec 4, 2024
0 parents commit 106e8ae
Show file tree
Hide file tree
Showing 16 changed files with 2,395 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build_CPU.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build_Subgen_Dockerfile_CPU

on:
push:
paths:
- 'requirements.txt'
- 'Dockerfile.cpu'
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get version from subgen.py
id: get_version
run: |
version=$(grep -oP "subgen_version\s*=\s*'\K[^']+" subgen.py)
echo "version=$version" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push CPU Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile.cpu
push: true
tags: |
mccloud/subgen:cpu
mccloud/subgen:${{ env.version }}-cpu
39 changes: 39 additions & 0 deletions .github/workflows/build_GPU.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build_Subgen_Dockerfile_GPU

on:
push:
paths:
- 'requirements.txt'
- 'Dockerfile'
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get version from subgen.py
id: get_version
run: |
version=$(grep -oP "subgen_version\s*=\s*'\K[^']+" subgen.py)
echo "version=$version" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push GPU Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
mccloud/subgen:latest
mccloud/subgen:${{ env.version }}
60 changes: 60 additions & 0 deletions .github/workflows/calver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Update_CalVer

on:
push:
branches:
- 'main'
paths:
- 'subgen.py'
- 'launcher.py'
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# Fetch only the latest commit initially
fetch-depth: 1
ref: main

- name: Fetch commits for this month
run: |
# Fetch commits starting from the first day of the current month
YEAR=$(date +%Y)
MONTH=$(date +%m)
git fetch --shallow-since="$YEAR-$MONTH-01"
- name: Calculate version
id: version
run: |
# Calculate the commit count for this month
YEAR=$(date +%Y)
MONTH=$(date +%m)
COMMIT_COUNT=$(git rev-list --count HEAD --since="$YEAR-$MONTH-01")
echo "COMMIT_COUNT=$COMMIT_COUNT"
echo "VERSION=${YEAR}.${MONTH}.${COMMIT_COUNT}" >> $GITHUB_ENV
- name: Update version file
run: |
# Update subgen.py with the calculated version
sed -i "s/subgen_version =.*/subgen_version = '${{ env.VERSION }}'/" subgen.py
- name: Amend commit with version update
env:
GIT_AUTHOR_NAME: "McCloudS"
GIT_AUTHOR_EMAIL: "[email protected]"
run: |
git config user.name "${GIT_AUTHOR_NAME}"
git config user.email "${GIT_AUTHOR_EMAIL}"
# Stage the modified file
git add subgen.py
# Amend the most recent commit, reusing the previous commit message
git commit --amend --reuse-message=HEAD --author="${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}>"
# Push the amended commit
git push --force
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.vscode/*

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

#ignore our settings
subgen.env

models/
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04

WORKDIR /subgen

ADD https://raw.githubusercontent.com/McCloudS/subgen/main/requirements.txt /subgen/requirements.txt

RUN apt-get update \
&& apt-get install -y \
python3 \
python3-pip \
ffmpeg \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install -r requirements.txt

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.py /subgen/subgen.py
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/language_code.py /subgen/language_code.py

CMD [ "bash", "-c", "python3 -u launcher.py" ]
23 changes: 23 additions & 0 deletions Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.11-slim-bullseye

WORKDIR /subgen

ADD https://raw.githubusercontent.com/McCloudS/subgen/main/requirements.txt /subgen/requirements.txt

RUN apt-get update \
&& apt-get install -y \
python3 \
python3-pip \
ffmpeg \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip install -r requirements.txt

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.py /subgen/subgen.py
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/language_code.py /subgen/language_code.py

CMD [ "bash", "-c", "python3 -u launcher.py" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 McCloudS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 106e8ae

Please sign in to comment.