瀏覽代碼

update model sizes

subDesTagesMitExtraKaese 1 年之前
父節點
當前提交
db5cc65a6a
共有 3 個文件被更改,包括 53 次插入7 次删除
  1. 34 4
      .github/workflows/docker.yml
  2. 1 1
      Dockerfile
  3. 18 2
      speech_recognition.py

+ 34 - 4
.github/workflows/docker.yml

@@ -45,6 +45,16 @@ jobs:
           tags: ftcaplan/matrix-stt-bot:tiny
           build-args: |
             "PRELOAD_MODEL=tiny"
+      -
+        name: Build and push
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          platforms: linux/amd64,linux/arm64/v8
+          push: true
+          tags: ftcaplan/matrix-stt-bot:tiny-q5_1
+          build-args: |
+            "PRELOAD_MODEL=tiny-q5_1"
       -
         name: Build and push
         uses: docker/build-push-action@v2
@@ -55,6 +65,16 @@ jobs:
           tags: ftcaplan/matrix-stt-bot:base
           build-args: |
             "PRELOAD_MODEL=base"
+      -
+        name: Build and push
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          platforms: linux/amd64,linux/arm64/v8
+          push: true
+          tags: ftcaplan/matrix-stt-bot:base-q5_1
+          build-args: |
+            "PRELOAD_MODEL=base-q5_1"
       -
         name: Build and push
         uses: docker/build-push-action@v2
@@ -72,9 +92,19 @@ jobs:
           context: .
           platforms: linux/amd64,linux/arm64/v8
           push: true
-          tags: ftcaplan/matrix-stt-bot:medium
+          tags: ftcaplan/matrix-stt-bot:small-q5_1
+          build-args: |
+            "PRELOAD_MODEL=small-q5_1"
+      -
+        name: Build and push
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          platforms: linux/amd64,linux/arm64/v8
+          push: true
+          tags: ftcaplan/matrix-stt-bot:medium-q5_0
           build-args: |
-            "PRELOAD_MODEL=medium"
+            "PRELOAD_MODEL=medium-q5_0"
       -
         name: Build and push
         uses: docker/build-push-action@v2
@@ -82,6 +112,6 @@ jobs:
           context: .
           platforms: linux/amd64,linux/arm64/v8
           push: true
-          tags: ftcaplan/matrix-stt-bot:large
+          tags: ftcaplan/matrix-stt-bot:large-q5_0
           build-args: |
-            "PRELOAD_MODEL=large"
+            "PRELOAD_MODEL=large-q5_0"

+ 1 - 1
Dockerfile

@@ -34,6 +34,6 @@ ADD ./*.py /app/
 
 ARG PRELOAD_MODEL
 ENV PRELOAD_MODEL ${PRELOAD_MODEL}
-RUN if [ -n "$PRELOAD_MODEL" ]; then wget "https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-$PRELOAD_MODEL.bin"; fi
+RUN if [ -n "$PRELOAD_MODEL" ]; then wget "https://ggml.ggerganov.com/ggml-model-whisper-$PRELOAD_MODEL.bin"; fi
 
 CMD ["python3", "-u", "main.py"]

+ 18 - 2
speech_recognition.py

@@ -27,7 +27,23 @@ def convert_audio(data: bytes, out_filename: str):
 
   return out
 
-MODELS = ["tiny.en", "tiny", "base.en", "base", "small.en", "small", "medium.en", "medium", "large"]
+MODELS = [
+  "tiny.en", 
+  "tiny.en-q5_1", 
+  "tiny", 
+  "tiny-q5_1", 
+  "base.en", 
+  "base.en-q5_1", 
+  "base", 
+  "base-q5_1", 
+  "small.en", 
+  "small.en-q5_1", 
+  "small", 
+  "small-q5_1",
+  "medium.en-q5_0", 
+  "medium-q5_0", 
+  "large-q5_0"
+]
 
 class ASR():
   def __init__(self, model = "tiny", language = "en"):
@@ -43,7 +59,7 @@ class ASR():
       if not os.path.exists("/data/models"):
         os.mkdir("/data/models")
         
-    self.model_url = f"https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-{self.model}.bin"
+    self.model_url = f"https://ggml.ggerganov.com/ggml-model-whisper-{self.model}.bin"
     self.lock = asyncio.Lock()
 
   def load_model(self):