Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import tempfile
|
|
| 5 |
import shutil
|
| 6 |
import torch
|
| 7 |
import os
|
|
|
|
| 8 |
from fastapi.middleware.cors import CORSMiddleware
|
| 9 |
from pydub import AudioSegment
|
| 10 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
|
@@ -63,6 +64,9 @@ async def transcribe(
|
|
| 63 |
if model_name not in AVAILABLE_MODELS:
|
| 64 |
return {"error": f"Modèle non reconnu. Choisissez parmi {AVAILABLE_MODELS}"}
|
| 65 |
|
|
|
|
|
|
|
|
|
|
| 66 |
# Charger modèle
|
| 67 |
model = load_model(model_name)
|
| 68 |
|
|
@@ -89,10 +93,14 @@ async def transcribe(
|
|
| 89 |
pdf_path = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf").name
|
| 90 |
generate_pdf(full_text, pdf_path)
|
| 91 |
|
|
|
|
|
|
|
|
|
|
| 92 |
return {
|
| 93 |
"model_used": model_name,
|
| 94 |
"language": info.language,
|
| 95 |
"probability": info.language_probability,
|
| 96 |
"transcription": full_text,
|
| 97 |
-
"pdf_file": pdf_path
|
| 98 |
-
|
|
|
|
|
|
| 5 |
import shutil
|
| 6 |
import torch
|
| 7 |
import os
|
| 8 |
+
import time
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
from pydub import AudioSegment
|
| 11 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
|
|
|
| 64 |
if model_name not in AVAILABLE_MODELS:
|
| 65 |
return {"error": f"Modèle non reconnu. Choisissez parmi {AVAILABLE_MODELS}"}
|
| 66 |
|
| 67 |
+
# Chronomètre début
|
| 68 |
+
start_time = time.time()
|
| 69 |
+
|
| 70 |
# Charger modèle
|
| 71 |
model = load_model(model_name)
|
| 72 |
|
|
|
|
| 93 |
pdf_path = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf").name
|
| 94 |
generate_pdf(full_text, pdf_path)
|
| 95 |
|
| 96 |
+
# Chronomètre fin
|
| 97 |
+
total_time = round(time.time() - start_time, 2)
|
| 98 |
+
|
| 99 |
return {
|
| 100 |
"model_used": model_name,
|
| 101 |
"language": info.language,
|
| 102 |
"probability": info.language_probability,
|
| 103 |
"transcription": full_text,
|
| 104 |
+
"pdf_file": pdf_path,
|
| 105 |
+
"processing_time_sec": total_time
|
| 106 |
+
}
|