repaire sentences
This commit is contained in:
@@ -43,6 +43,8 @@ from .models import (
|
||||
CourseSummary,
|
||||
CourseTitleUpdate,
|
||||
SentenceBoundaryAdjust,
|
||||
SentenceGapRepairRequest,
|
||||
SentenceGapRepairResponse,
|
||||
SentenceBoundary,
|
||||
SentenceBoundaryDocument,
|
||||
SentenceExplanationRequest,
|
||||
@@ -688,6 +690,34 @@ def create_app(
|
||||
background_tasks.add_task(_process_safely, processor, video_hash)
|
||||
return {"video_hash": video_hash.lower(), "status": "processing_queued"}
|
||||
|
||||
@application.post(
|
||||
"/api/v1/admin/videos/{video_hash}/repair-gaps",
|
||||
response_model=SentenceGapRepairResponse,
|
||||
dependencies=[Depends(require_admin)],
|
||||
)
|
||||
async def repair_sentence_gaps(
|
||||
payload: Optional[SentenceGapRepairRequest] = None,
|
||||
video_hash: str = SHA256_PATH,
|
||||
) -> SentenceGapRepairResponse:
|
||||
request = payload or SentenceGapRepairRequest()
|
||||
try:
|
||||
result = await run_in_threadpool(
|
||||
processor.repair_gaps,
|
||||
video_hash,
|
||||
request.min_gap_ms,
|
||||
)
|
||||
except KeyError:
|
||||
raise HTTPException(status_code=404, detail="Video was not found.") from None
|
||||
except FileNotFoundError as exc:
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
except RuntimeError as exc:
|
||||
raise HTTPException(status_code=503, detail=str(exc)) from exc
|
||||
if result["inserted_count"]:
|
||||
application.state.subtitle_translations.start_missing(video_hash)
|
||||
return SentenceGapRepairResponse(video_hash=video_hash.lower(), **result)
|
||||
|
||||
@application.get(
|
||||
"/api/v1/admin/videos/{video_hash}/subtitle-translation",
|
||||
response_model=AdminSubtitleTranslationResponse,
|
||||
|
||||
Reference in New Issue
Block a user