From 7567f1ffe2832239251171aa693f55c4770f5e20 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 7 Jul 2024 15:46:41 +0100 Subject: [PATCH] make it run --- README.md | 8 ++++++++ transcribe.py | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 91ff46f..d0092f2 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,14 @@ use whisper_timestamped to add automatic transcriptions to pan.do/ra add "transcribe" to LOCAL_APPS in local_setttings.py +## install whisper_timestamped + + python3 -m venv venv /opt/whisper-timestamped/ + /opt/whisper-timestamped/bin/pip install \ + torch==1.13.1+cpu \ + torchaudio==0.13.1+cpu \ + -f https://download.pytorch.org/whl/torch_stable.html + /opt/whisper-timestamped/bin/pip install whisper-timestamped ## configuration diff --git a/transcribe.py b/transcribe.py index 9793553..75ebfbb 100644 --- a/transcribe.py +++ b/transcribe.py @@ -4,6 +4,7 @@ import shutil import signal import subprocess import tempfile +import time import ox import ox.iso @@ -11,9 +12,10 @@ import ox.iso from django.conf import settings from annotation import tasks -from item.models import Item -from itemlist.models import List from item import utils +from itemlist.models import List +from item.models import Item +from user.models import User logger = logging.getLogger(__name__) @@ -80,9 +82,9 @@ def extract_subtitles(item, user, layer, translate, gpu=False): def main(**kwargs): - queue = List.objects.get(kwargs['queue']) - done = List.objects.get(kwargs['done']) - user = User.objects.get(kwargs['user']) + user = User.objects.get(username=kwargs['user']) + queue = List.objects.get(user=user, name=kwargs['queue']) + done = List.objects.get(user=user, name=kwargs['done']) layer = kwargs.get("layer") translate = kwargs.get("translate") if translate: @@ -97,7 +99,7 @@ def main(**kwargs): try: while True: wait = True - for item in queue.get_items(queue.user): + for item in queue.get_items(queue.user).all(): if extract_subtitles(item, user, layer, translate, kwargs.get("gpu")): queue.items.remove(item) done.items.remove(item)