mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
update HTTP POST
This commit is contained in:
@@ -151,7 +151,7 @@ class Whisper:
|
|||||||
)
|
)
|
||||||
@asgi_app()
|
@asgi_app()
|
||||||
def web():
|
def web():
|
||||||
from fastapi import Depends, FastAPI, Form, HTTPException, UploadFile, status
|
from fastapi import Body, Depends, FastAPI, HTTPException, UploadFile, status
|
||||||
from fastapi.security import OAuth2PasswordBearer
|
from fastapi.security import OAuth2PasswordBearer
|
||||||
from typing_extensions import Annotated
|
from typing_extensions import Annotated
|
||||||
|
|
||||||
@@ -173,26 +173,23 @@ def web():
|
|||||||
class TranscriptResponse(BaseModel):
|
class TranscriptResponse(BaseModel):
|
||||||
result: dict
|
result: dict
|
||||||
|
|
||||||
class TranscriptRequest(BaseModel):
|
|
||||||
file: UploadFile
|
|
||||||
timestamp: Annotated[float, Form()] = 0
|
|
||||||
source_language: Annotated[str, Form()] = "en"
|
|
||||||
target_language: Annotated[str, Form()] = "en"
|
|
||||||
|
|
||||||
@app.post("/transcribe", dependencies=[Depends(apikey_auth)])
|
@app.post("/transcribe", dependencies=[Depends(apikey_auth)])
|
||||||
async def transcribe(
|
async def transcribe(
|
||||||
req: TranscriptRequest
|
file: UploadFile,
|
||||||
|
source_language: Annotated[str, Body(...)] = "en",
|
||||||
|
target_language: Annotated[str, Body(...)] = "en",
|
||||||
|
timestamp: Annotated[float, Body()] = 0.0
|
||||||
) -> TranscriptResponse:
|
) -> TranscriptResponse:
|
||||||
audio_data = await req.file.read()
|
audio_data = await file.read()
|
||||||
audio_suffix = req.file.filename.split(".")[-1]
|
audio_suffix = file.filename.split(".")[-1]
|
||||||
assert audio_suffix in supported_audio_file_types
|
assert audio_suffix in supported_audio_file_types
|
||||||
|
|
||||||
func = transcriberstub.transcribe_segment.spawn(
|
func = transcriberstub.transcribe_segment.spawn(
|
||||||
audio_data=audio_data,
|
audio_data=audio_data,
|
||||||
audio_suffix=audio_suffix,
|
audio_suffix=audio_suffix,
|
||||||
source_language=req.source_language,
|
source_language=source_language,
|
||||||
target_language=req.target_language,
|
target_language=target_language,
|
||||||
timestamp=req.timestamp
|
timestamp=timestamp
|
||||||
)
|
)
|
||||||
result = func.get()
|
result = func.get()
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class AudioTranscriptModalProcessor(AudioTranscriptProcessor):
|
|||||||
files=files,
|
files=files,
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
data=json_payload,
|
params=json_payload,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
|
|||||||
Reference in New Issue
Block a user