feat(backend): add direct /salute-speech/ transcription endpoint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ from cpv3.db.session import get_db
|
|||||||
from cpv3.modules.transcription.schemas import (
|
from cpv3.modules.transcription.schemas import (
|
||||||
Document,
|
Document,
|
||||||
GoogleSpeechParams,
|
GoogleSpeechParams,
|
||||||
|
SaluteSpeechParams,
|
||||||
TranscriptionCreate,
|
TranscriptionCreate,
|
||||||
TranscriptionRead,
|
TranscriptionRead,
|
||||||
TranscriptionUpdate,
|
TranscriptionUpdate,
|
||||||
@@ -19,6 +20,7 @@ from cpv3.modules.transcription.schemas import (
|
|||||||
)
|
)
|
||||||
from cpv3.modules.transcription.service import (
|
from cpv3.modules.transcription.service import (
|
||||||
transcribe_with_google_speech,
|
transcribe_with_google_speech,
|
||||||
|
transcribe_with_salute_speech,
|
||||||
transcribe_with_whisper,
|
transcribe_with_whisper,
|
||||||
)
|
)
|
||||||
from cpv3.modules.transcription.repository import TranscriptionRepository
|
from cpv3.modules.transcription.repository import TranscriptionRepository
|
||||||
@@ -62,7 +64,7 @@ async def retrieve_transcription_entry(
|
|||||||
repo = TranscriptionRepository(db)
|
repo = TranscriptionRepository(db)
|
||||||
transcription = await repo.get_by_id(transcription_id)
|
transcription = await repo.get_by_id(transcription_id)
|
||||||
if transcription is None:
|
if transcription is None:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not found")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Не найдено")
|
||||||
|
|
||||||
return TranscriptionRead.model_validate(transcription)
|
return TranscriptionRead.model_validate(transcription)
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ async def retrieve_transcription_by_artifact(
|
|||||||
repo = TranscriptionRepository(db)
|
repo = TranscriptionRepository(db)
|
||||||
transcription = await repo.get_by_artifact_id(artifact_id)
|
transcription = await repo.get_by_artifact_id(artifact_id)
|
||||||
if transcription is None:
|
if transcription is None:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not found")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Не найдено")
|
||||||
|
|
||||||
return TranscriptionRead.model_validate(transcription)
|
return TranscriptionRead.model_validate(transcription)
|
||||||
|
|
||||||
@@ -93,7 +95,7 @@ async def patch_transcription_entry(
|
|||||||
repo = TranscriptionRepository(db)
|
repo = TranscriptionRepository(db)
|
||||||
transcription = await repo.get_by_id(transcription_id)
|
transcription = await repo.get_by_id(transcription_id)
|
||||||
if transcription is None:
|
if transcription is None:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not found")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Не найдено")
|
||||||
|
|
||||||
transcription = await repo.update(transcription, body)
|
transcription = await repo.update(transcription, body)
|
||||||
return TranscriptionRead.model_validate(transcription)
|
return TranscriptionRead.model_validate(transcription)
|
||||||
@@ -109,7 +111,7 @@ async def delete_transcription_entry(
|
|||||||
repo = TranscriptionRepository(db)
|
repo = TranscriptionRepository(db)
|
||||||
transcription = await repo.get_by_id(transcription_id)
|
transcription = await repo.get_by_id(transcription_id)
|
||||||
if transcription is None:
|
if transcription is None:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not found")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Не найдено")
|
||||||
|
|
||||||
await repo.deactivate(transcription)
|
await repo.deactivate(transcription)
|
||||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||||
@@ -142,3 +144,18 @@ async def google_speech_transcribe(
|
|||||||
file_key=body.file_path,
|
file_key=body.file_path,
|
||||||
language_codes=body.language_codes,
|
language_codes=body.language_codes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/salute-speech/", response_model=Document)
|
||||||
|
async def salute_speech_transcribe(
|
||||||
|
body: SaluteSpeechParams,
|
||||||
|
current_user: User = Depends(get_current_user),
|
||||||
|
storage: StorageService = Depends(get_storage),
|
||||||
|
) -> Document:
|
||||||
|
_ = current_user
|
||||||
|
return await transcribe_with_salute_speech(
|
||||||
|
storage,
|
||||||
|
file_key=body.file_path,
|
||||||
|
language=body.language,
|
||||||
|
model=body.model,
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user