Spaces:
Sleeping
Sleeping
import time | |
from fastapi import APIRouter, Depends, HTTPException, status | |
from libs.transformer.get_transcript_2 import get_transcribe_transformers | |
from libs.header_api_auth import get_api_key | |
router = APIRouter(prefix="/get-transcript-transformer", tags=["transcript"]) | |
def get_transcript(audio_path: str, api_key: str = Depends(get_api_key)): | |
st = time.time() | |
try: | |
text, chunks = get_transcribe_transformers(audio_path) | |
except Exception as error: | |
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=f"error>>>: {error}") | |
listSentences = [] | |
for chunk in chunks: | |
listSentences.append({ | |
"start_time": chunk.get("timestamp")[0], | |
"end_time": chunk.get("timestamp")[1], | |
"text": chunk.get("text") | |
}) | |
et = time.time() | |
elapsed_time = et - st | |
return {"text": text, | |
'list_sentence': listSentences, | |
'elapsed_time': round(elapsed_time, 2) | |
} | |