File size: 942 Bytes
252d749
 
 
 
385a3d3
 
252d749
 
 
 
 
 
385a3d3
78f1df3
 
385a3d3
 
 
e55694e
7306982
385a3d3
7306982
 
dd2695b
af5c58a
7306982
 
385a3d3
dd2695b
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from celery import Celery
import os
import time
from App import celery_config
import yt_dlp
import tempfile
from App.Transcription.Utils.audio_transcription import transcribe_file

celery = Celery()
celery.config_from_object(celery_config)


@celery.task(name="transcription", bind=True)
def transcription_task(self, file_path, model_size="tiny"):
    return transcribe_file(state=self, file_path=file_path, model_size=model_size)


@celery.task(name="download", bind=True)
def downloadfile(self, url, ydl_opts, model_size="tiny"):
    # updated
    self.update_state(state="Downloading File..", meta={})

    ####
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        ydl.download([url])

    # updated
    self.update_state(state="Downloading complete", meta={})
    audio_file = ydl_opts["outtmpl"]
    print(audio_file["default"])
    return transcribe_file(
        state=self, file_path=audio_file["default"], model_size=model_size
    )