fair
Browse files- App/Transcription/TranscriptionRoutes.py +7 -2
- App/Worker.py +2 -2
- app.py +2 -2
App/Transcription/TranscriptionRoutes.py
CHANGED
@@ -21,6 +21,11 @@ transcription_router = APIRouter(tags=["Transcription"])
|
|
21 |
async def download_audio(
|
22 |
url: str,
|
23 |
userId: int = 1,
|
|
|
|
|
|
|
|
|
|
|
24 |
):
|
25 |
user = await User.objects.filter(id=userId).first()
|
26 |
if user == None:
|
@@ -34,9 +39,9 @@ async def download_audio(
|
|
34 |
"preferredquality": "192",
|
35 |
}
|
36 |
],
|
37 |
-
"outtmpl": os.path.join(tempfile.gettempdir(), "%(title)s
|
38 |
}
|
39 |
-
task = downloadfile.delay(url, ydl_opts)
|
40 |
transcription_enrty = await Transcriptions.objects.create(
|
41 |
task_id=task.id, user=user
|
42 |
)
|
|
|
21 |
async def download_audio(
|
22 |
url: str,
|
23 |
userId: int = 1,
|
24 |
+
model: str = Query(
|
25 |
+
"tiny",
|
26 |
+
enum=["tiny", "small", "medium", "base", "large-v2"],
|
27 |
+
description="Whisper model Sizes",
|
28 |
+
),
|
29 |
):
|
30 |
user = await User.objects.filter(id=userId).first()
|
31 |
if user == None:
|
|
|
39 |
"preferredquality": "192",
|
40 |
}
|
41 |
],
|
42 |
+
"outtmpl": os.path.join(tempfile.gettempdir(), "%(title)s.mp3"),
|
43 |
}
|
44 |
+
task = downloadfile.delay(url, ydl_opts, model)
|
45 |
transcription_enrty = await Transcriptions.objects.create(
|
46 |
task_id=task.id, user=user
|
47 |
)
|
App/Worker.py
CHANGED
@@ -16,7 +16,7 @@ def transcription_task(self, file_path, model_size="tiny"):
|
|
16 |
|
17 |
|
18 |
@celery.task(name="download", bind=True)
|
19 |
-
def downloadfile(self, url, ydl_opts):
|
20 |
# updated
|
21 |
self.update_state(state="Downloading File..", meta={})
|
22 |
|
@@ -28,4 +28,4 @@ def downloadfile(self, url, ydl_opts):
|
|
28 |
# updated
|
29 |
self.update_state(state="Downloading complete", meta={})
|
30 |
|
31 |
-
return transcribe_file(state=self, file_path=audio_file, model_size=
|
|
|
16 |
|
17 |
|
18 |
@celery.task(name="download", bind=True)
|
19 |
+
def downloadfile(self, url, ydl_opts, model_size="tiny"):
|
20 |
# updated
|
21 |
self.update_state(state="Downloading File..", meta={})
|
22 |
|
|
|
28 |
# updated
|
29 |
self.update_state(state="Downloading complete", meta={})
|
30 |
|
31 |
+
return transcribe_file(state=self, file_path=audio_file, model_size=model_size)
|
app.py
CHANGED
@@ -20,6 +20,6 @@ def run_command(command):
|
|
20 |
|
21 |
|
22 |
# Example usage
|
23 |
-
command = "uvicorn App.app:app --host 0.0.0.0 --port 7860"
|
24 |
run_command(command)
|
25 |
-
"python3.10 -m celery -A App.Worker.celery worker -c 8 --loglevel=info"
|
|
|
20 |
|
21 |
|
22 |
# Example usage
|
23 |
+
command = "uvicorn App.app:app --host 0.0.0.0 --port 7860 & celery -A App.Worker.celery worker -c 8 --loglevel=info"
|
24 |
run_command(command)
|
25 |
+
# "python3.10 -m celery -A App.Worker.celery worker -c 8 --loglevel=info"
|