get all transcriptions
Browse files
App/Transcription/Schemas.py
CHANGED
@@ -11,6 +11,14 @@ class TranscriptionMetadata(BaseModel):
|
|
11 |
state: str = "PENDING"
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
class TranscriptionResult(BaseModel):
|
15 |
created_at: datetime = Field(default_factory=datetime.utcnow)
|
16 |
duration: int = 0
|
|
|
11 |
state: str = "PENDING"
|
12 |
|
13 |
|
14 |
+
class BaseTranscription(BaseModel):
|
15 |
+
created_at: datetime = Field(default_factory=datetime.utcnow)
|
16 |
+
duration: int = 0
|
17 |
+
language: str = "-"
|
18 |
+
transcription_state: str = "SUCCESS"
|
19 |
+
content: list = []
|
20 |
+
|
21 |
+
|
22 |
class TranscriptionResult(BaseModel):
|
23 |
created_at: datetime = Field(default_factory=datetime.utcnow)
|
24 |
duration: int = 0
|
App/Transcription/TranscriptionRoutes.py
CHANGED
@@ -1,6 +1,11 @@
|
|
1 |
from fastapi import APIRouter, status, Depends, UploadFile, File, Query, BackgroundTasks
|
2 |
from typing_extensions import Annotated
|
3 |
-
from .Schemas import
|
|
|
|
|
|
|
|
|
|
|
4 |
from App import bot
|
5 |
import aiofiles, os, re
|
6 |
import tempfile
|
@@ -62,6 +67,15 @@ async def download_audio(
|
|
62 |
return response
|
63 |
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
@transcription_router.post("/uploadfile/")
|
66 |
async def create_file(
|
67 |
background_tasks: BackgroundTasks,
|
|
|
1 |
from fastapi import APIRouter, status, Depends, UploadFile, File, Query, BackgroundTasks
|
2 |
from typing_extensions import Annotated
|
3 |
+
from .Schemas import (
|
4 |
+
UserDetails,
|
5 |
+
TranscriptionMetadata,
|
6 |
+
TranscriptionResult,
|
7 |
+
BaseTranscription,
|
8 |
+
)
|
9 |
from App import bot
|
10 |
import aiofiles, os, re
|
11 |
import tempfile
|
|
|
67 |
return response
|
68 |
|
69 |
|
70 |
+
@transcription_router.get("/transcriptions")
|
71 |
+
async def get_user_transcriptions(
|
72 |
+
user: UserSchema = Depends(get_token_owner),
|
73 |
+
):
|
74 |
+
transcriptions = await Transcriptions.objects.filter(user=user).all()
|
75 |
+
objects = [BaseTranscription(**obj.__dict__) for obj in transcriptions]
|
76 |
+
return objects
|
77 |
+
|
78 |
+
|
79 |
@transcription_router.post("/uploadfile/")
|
80 |
async def create_file(
|
81 |
background_tasks: BackgroundTasks,
|