45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import logging
|
|
|
|
from app.celery import app
|
|
from django.conf import settings
|
|
|
|
from item import utils
|
|
from user.models import User
|
|
from item.models import Item
|
|
|
|
from . import transcribe
|
|
|
|
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(layers, 'isSubtitles', True)
|
|
|
|
gpu = getattr(settings, "TRANSCRIBE_GPU", False)
|
|
join_sentences = getattr(settings, "TRANSCRIBE_JOIN", False)
|
|
model = getattr(settings, "TRANSCRIBE_MODEL", "small")
|
|
translate = getattr(settings, "TRANSCRIBE_TRANSLATE", "")
|
|
logger.error(
|
|
"transcribe %s %s %s %s %s %s %s",
|
|
item,
|
|
user,
|
|
subtitles,
|
|
translate,
|
|
gpu,
|
|
join_sentences,
|
|
model
|
|
)
|
|
|
|
transcribe.extract_subtitles(
|
|
item,
|
|
user,
|
|
subtitles,
|
|
translate,
|
|
gpu,
|
|
join_sentences=join_sentences,
|
|
model=model
|
|
)
|