0
0

Added Whisper-ctranslate2

This commit is contained in:
Opnxng 2023-12-19 11:38:14 +08:00
parent 53bea4c8aa
commit f23e8bedcc
2 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,73 @@
name: whisper-ctranslate2
run-name: whisper-ctranslate2
env:
REPO_NAME: whisper-ctranslate2
REMOTE_REPO: https://github.com/Softcatala/whisper-ctranslate2.git
BUILD_PLATFORM: linux/arm64
on:
schedule:
- cron: "0 0 1 * *" # monthly
push:
paths:
- ".gitea/workflows/whisper-ctranslate2.yaml"
jobs:
build:
runs-on: runner
container:
image: docker:cli
steps:
- name: Install packages
run: apk --no-cache add curl git jq
- name: Check latest upstream commit
run: |
STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1)
LATEST_COMMIT=$(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1)
echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV"
echo "LATEST_COMMIT=${LATEST_COMMIT}" >> "$GITHUB_ENV"
echo "Stored Commit: ${STORED_COMMIT}"
echo "Latest Commit: ${LATEST_COMMIT}"
- name: Build and push Docker image
run: |
if [ "$STORED_COMMIT" != "$LATEST_COMMIT" ]; then
echo "Found a new commit, building new image"
# Install Docker Buildx
BUILDX_VERSION=$(wget -q -O- https://api.github.com/repos/docker/buildx/releases/latest | jq -r '.name')
wget -O /usr/bin/docker-buildx https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.linux-arm64
chmod +x /usr/bin/docker-buildx
# Create and use Docker Buildx builder
docker-buildx create --use --name buildx
# Login to Package Registry
echo "${{ secrets.TOKEN }}" | docker login git.opnxng.com -u ${{ gitea.repository_owner }} --password-stdin
# Build and push Docker image
mkdir temp
cd temp
git clone ${REMOTE_REPO} .
curl -JL https://git.opnxng.com/opnxng/docker-images/raw/branch/main/dockerfiles/whisper-ctranslate2.Dockerfile -o Dockerfile
docker-buildx build \
--platform ${BUILD_PLATFORM} \
-t git.opnxng.com/${{ gitea.repository_owner }}/${REPO_NAME}:latest \
-f ./Dockerfile \
--push . && \
curl -H prio:low -d "Built and pushed ${REPO_NAME}" https://ntfy.opnxng.com/build || \
{ curl -H tags:warning -H prio:high -d "Built and pushed ${REPO_NAME} failed!" https://ntfy.opnxng.com/build ; exit 1; }
# Remove Docker Buildx builder
docker-buildx rm buildx
else
echo "No new commit, skipped build"
fi
- name: Update stored commit
run: |
if [ "$STORED_COMMIT" != "$LATEST_COMMIT" ]; then
curl -H "Authorization: Bearer ${{ secrets.NT }}" -d $(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1) "https://nt.opnxng.com/${REPO_NAME}"
STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1)
echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV"
else
curl -H "Authorization: Bearer ${{ secrets.NT }}" -d $(git ls-remote ${REMOTE_REPO} | awk '{print $1}' | head -1) "https://nt.opnxng.com/${REPO_NAME}"
STORED_COMMIT=$(curl -H "Authorization: Bearer ${{ secrets.NT }}" -s "https://nt.opnxng.com/${REPO_NAME}/raw?poll=1" | tail -n 1)
echo "STORED_COMMIT=${STORED_COMMIT}" >> "$GITHUB_ENV"
exit 1
fi

View File

@ -0,0 +1,23 @@
# Use the base image with CUDA and cuDNN support
#FROM nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu20.04
# Use Ubuntu as base
FROM ubuntu:20.04
# Install necessary dependencies
RUN apt-get update && apt-get install -y python3-pip
# Set the working directory
WORKDIR /app
# Copy the app code and requirements filed
COPY . /app
# Install the app dependencies
RUN pip3 install --no-cache-dir -r requirements.txt
# Install whisper-ctranslate2
RUN pip install -U whisper-ctranslate2
# Set the entry point
# ENTRYPOINT ["whisper-ctranslate2"]