35 lines
967 B
Python
35 lines
967 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
import logging
|
|
|
|
from app.celery import app
|
|
from django.conf import settings
|
|
|
|
from item import utils
|
|
from item.models import Item
|
|
from taskqueue.models import Task
|
|
from user.models import User
|
|
|
|
from .transcribe import extract_subtitles
|
|
|
|
logger = logging.getLogger('pandora.' + __name__)
|
|
|
|
@app.task(queue='encoding')
|
|
def transcribe(**kwargs):
|
|
user = User.objects.get(username=kwargs["user"])
|
|
item = Item.objects.get(public_id=kwargs["item"])
|
|
subtitles = utils.get_by_key(settings.CONFIG['layers'], 'isSubtitles', True)['id']
|
|
|
|
gpu = getattr(settings, "TRANSCRIBE_GPU", False)
|
|
join_sentences = getattr(settings, "TRANSCRIBE_JOIN", False)
|
|
model = getattr(settings, "TRANSCRIBE_MODEL", "small")
|
|
translate = getattr(settings, "TRANSCRIBE_TRANSLATE", "")
|
|
extract_subtitles(
|
|
item,
|
|
user,
|
|
subtitles,
|
|
translate,
|
|
gpu,
|
|
join_sentences=join_sentences,
|
|
model=model
|
|
)
|