Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ import numpy as np
|
|
13 |
import json
|
14 |
import tempfile
|
15 |
from fastapi import FastAPI, UploadFile, File, HTTPException, Form, BackgroundTasks
|
16 |
-
from fastapi.responses import FileResponse, JSONResponse
|
17 |
from fastapi.middleware.cors import CORSMiddleware
|
18 |
from transformers import pipeline, AutoModelForQuestionAnswering, AutoTokenizer
|
19 |
from sentence_transformers import SentenceTransformer
|
@@ -441,7 +441,7 @@ async def analyze_legal_audio(file: UploadFile = File(...), background_tasks: Ba
|
|
441 |
with tempfile.NamedTemporaryFile(delete=False, suffix=os.path.splitext(file.filename)[1]) as temp_file:
|
442 |
temp_file.write(content)
|
443 |
temp_file_path = temp_file.name
|
444 |
-
text = await process_audio_to_text(temp_file_path)
|
445 |
if os.path.exists(temp_file_path):
|
446 |
os.remove(temp_file_path)
|
447 |
if not text:
|
@@ -649,4 +649,3 @@ if __name__ == "__main__":
|
|
649 |
else:
|
650 |
print("\n⚠️ Ngrok setup failed. API will only be available locally.\n")
|
651 |
run()
|
652 |
-
|
|
|
13 |
import json
|
14 |
import tempfile
|
15 |
from fastapi import FastAPI, UploadFile, File, HTTPException, Form, BackgroundTasks
|
16 |
+
from fastapi.responses import FileResponse, JSONResponse, HTMLResponse # Added HTMLResponse
|
17 |
from fastapi.middleware.cors import CORSMiddleware
|
18 |
from transformers import pipeline, AutoModelForQuestionAnswering, AutoTokenizer
|
19 |
from sentence_transformers import SentenceTransformer
|
|
|
441 |
with tempfile.NamedTemporaryFile(delete=False, suffix=os.path.splitext(file.filename)[1]) as temp_file:
|
442 |
temp_file.write(content)
|
443 |
temp_file_path = temp_file.name
|
444 |
+
text = await process_audio_to_text(temp_audio_path=temp_file_path)
|
445 |
if os.path.exists(temp_file_path):
|
446 |
os.remove(temp_file_path)
|
447 |
if not text:
|
|
|
649 |
else:
|
650 |
print("\n⚠️ Ngrok setup failed. API will only be available locally.\n")
|
651 |
run()
|
|