created entries to the db
Browse files
App/Transcription/Model.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import orm
|
2 |
import datetime
|
3 |
from App.modelInit import database, models
|
|
|
4 |
|
5 |
|
6 |
class Transcriptions(orm.Model):
|
@@ -8,6 +9,7 @@ class Transcriptions(orm.Model):
|
|
8 |
registry = models
|
9 |
fields = {
|
10 |
"id": orm.Integer(primary_key=True),
|
|
|
11 |
"tl_file_id": orm.String(max_length=100, index=True, default=""),
|
12 |
"user": orm.ForeignKey(User, on_delete=orm.CASCADE),
|
13 |
"createdAt": orm.DateTime(index=True, default=datetime.datetime.now),
|
|
|
1 |
import orm
|
2 |
import datetime
|
3 |
from App.modelInit import database, models
|
4 |
+
from App.Users.Model import User
|
5 |
|
6 |
|
7 |
class Transcriptions(orm.Model):
|
|
|
9 |
registry = models
|
10 |
fields = {
|
11 |
"id": orm.Integer(primary_key=True),
|
12 |
+
"task_id": orm.String(max_length=100, index=True, default=""),
|
13 |
"tl_file_id": orm.String(max_length=100, index=True, default=""),
|
14 |
"user": orm.ForeignKey(User, on_delete=orm.CASCADE),
|
15 |
"createdAt": orm.DateTime(index=True, default=datetime.datetime.now),
|
App/Transcription/TranscriptionRoutes.py
CHANGED
@@ -5,6 +5,8 @@ from App import bot
|
|
5 |
import aiofiles
|
6 |
from celery.result import AsyncResult
|
7 |
from App.Worker import transcription_task
|
|
|
|
|
8 |
|
9 |
# from .Model import User
|
10 |
# from sqlalchemy import and_
|
@@ -23,6 +25,10 @@ async def create_file(
|
|
23 |
description="Whisper model Sizes",
|
24 |
),
|
25 |
):
|
|
|
|
|
|
|
|
|
26 |
# Write the file to disk asynchronously
|
27 |
try:
|
28 |
async with aiofiles.open(file.filename, "wb") as f:
|
@@ -44,6 +50,8 @@ async def create_file(
|
|
44 |
# celery task
|
45 |
task = transcription_task.delay(file.filename, model)
|
46 |
|
|
|
|
|
47 |
return {
|
48 |
"file_size": file.size,
|
49 |
"file_name": file.filename,
|
|
|
5 |
import aiofiles
|
6 |
from celery.result import AsyncResult
|
7 |
from App.Worker import transcription_task
|
8 |
+
from App.Users.Model import User
|
9 |
+
from .Model import Transcriptions
|
10 |
|
11 |
# from .Model import User
|
12 |
# from sqlalchemy import and_
|
|
|
25 |
description="Whisper model Sizes",
|
26 |
),
|
27 |
):
|
28 |
+
user = await User.objects.filter(id=userId).first()
|
29 |
+
if user != None:
|
30 |
+
return {"code": 400, "message": "user exists", "payload": None}
|
31 |
+
|
32 |
# Write the file to disk asynchronously
|
33 |
try:
|
34 |
async with aiofiles.open(file.filename, "wb") as f:
|
|
|
50 |
# celery task
|
51 |
task = transcription_task.delay(file.filename, model)
|
52 |
|
53 |
+
# create a transcription entry
|
54 |
+
transcription_enrty = Transcriptions.objects.create(task_id=task.id, user=user)
|
55 |
return {
|
56 |
"file_size": file.size,
|
57 |
"file_name": file.filename,
|