diff --git a/.gitignore b/.gitignore index bf4d3b6..99832d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,48 +1,7 @@ env/* databases/storage.db -4b751a4425c2884286a92fde2de6427f_trusted.table -4b751a4425c2884286a92fde2de6427f_analitic.table -4b751a4425c2884286a92fde2de6427f_analitic_voice.table -4b751a4425c2884286a92fde2de6427f_analitic_llm.table -4b751a4425c2884286a92fde2de6427f_analitic_ocr.table +*.table .vscode/* __pycache__/* - conf/experiment_config.json -example/Gmail.zip -example/Gmail/20240530_112812.jpg -example/Gmail/20240530_112825.jpg -example/Gmail/20240530_112925.jpg -example/Gmail/20240530_113110.jpg -example/Gmail/20240530_113114.jpg -example/Gmail/20240530_113531.jpg -example/Gmail/20240530_113555.jpg -example/Gmail/20240530_113614.jpg -example/Gmail/20240530_113650.jpg -example/Gmail/20240530_113731.jpg -example/audio/audio-file.flac -example/audio/audio-file2.flac -example/audio/AwACAgEAAxkBAAIBw2YX8o2vGGCNtZCXk7mY1Bm5w__lAAJmBAACxe7ARI1fUWAGcz_RNAQ.ogg -example/audio/AwACAgEAAxkBAAIBxWYX8z-FgaOqQ5wJ4588Oa4wKNbsAAJnBAACxe7AREtzfoE98xYHNAQ.ogg -example/audio/AwACAgEAAxkBAAIByGYX-NDzOEo-RH2YjEgG081ujEd-AAIQBAACS5vARIG7Bw8TVGr2NAQ.ogg -example/audio/AwACAgEAAxkBAANfZg2OE9Zvvn_7jJl7DaoD0j4kQQwAAqkEAAI-a3FEcjssrLJQjM00BA.ogg -example/audio/AwACAgEAAxkBAANhZg2U46T2Q6UYZ9gl3fHJsmJx2XcAAtgEAAI5ImlETOJIxvExjdg0BA.ogg -example/audio/AwACAgEAAxkBAANjZg2VEKqY04rTspcLw7trMmKPw58AAtkEAAI5ImlEZ18o0TpHffc0BA.ogg -example/audio/AwACAgEAAxkBAANlZg2WB8W9V-L0qkNENZrH1M1FZ5oAAtoEAAI5ImlEq70kYsaMeAs0BA.ogg -example/audio/AwACAgEAAxkBAANmZg2WDkyaygSa1QJvcSfYs6mNspcAAtsEAAI5ImlEfDhlNAY1KXs0BA.ogg -example/audio/AwACAgEAAxkBAANpZhcNbIqGT8cK3erus_8QoSBqkaMAAiEEAAIpsrhELqtOLaMMSf40BA.ogg -example/audio/AwACAgEAAxkBAANtZhcOLk3GkB7sTJ8HYUqjsmwjrNwAAiQEAAIpsrhEGvkyIIq7LKc0BA.ogg -example/audio/file_96.oga -example/audio/Prueba3.wav -example/audio/sin nombre.ogg -example/factura/Factura1.jpg -example/factura/Factura2.jpg -example/factura/Factura3.jpeg -example/factura/Factura4.jpg -example/factura/Factura5.jpg -example/factura/Factura6.jpg -example/texto/7fad5a297eb94ff9dbb3eff8e889a1c7dd87fe0f7c6bb6130f268acbfd828736.txt -4b751a4425c2884286a92fde2de6427f_analitic_llm_rag.table -4b751a4425c2884286a92fde2de6427f_analitic_llm_generaciontexto.table -4b751a4425c2884286a92fde2de6427f_analitic_llm_factura.table -4b751a4425c2884286a92fde2de6427f_analitic_llm_compra.table +example/* \ No newline at end of file diff --git a/apis.py b/apis.py index c5928eb..d35ca0a 100644 --- a/apis.py +++ b/apis.py @@ -16,6 +16,8 @@ import statistics import hashlib from datetime import datetime import json +import uuid +import shutil pwd = os.getcwd() pathAud="example/audio" pathFact="example/factura" @@ -84,6 +86,177 @@ class Response5(BaseModel): #Funcionales + +@app.post("/uploadimg") +def upload_image(image: UploadFile = File(...),type="factura"): + endfile=".jpg" + t=time.time() + print(image.headers) + try: + # Create a temporary file to store the uploaded audio + headfilename=uuid.uuid4() + filename="example/%s/"%(type)+str(headfilename)+endfile + with open(f"{filename}", "wb") as buffer: + shutil.copyfileobj(image.file, buffer) + return JSONResponse(content={ + "message": filename, + "time":time.time()-t + }, status_code=200) + + except Exception as e: + return JSONResponse(content={ + "message": f"There was an error uploading the file: {str(e)}" + }, status_code=500) + + +@app.post("/uploadaud") +def upload_audio(audio: UploadFile = File(...)): + if audio.headers['content-type']=="audio/wav": + endfile=".wav" + if audio.headers['content-type']=="audio/ogg": + endfile=".ogg" + if audio.headers['content-type']=="video/webm": + endfile=".webm" + type="audio" + try: + # Create a temporary file to store the uploaded audio + headfilename=uuid.uuid4() + filename="example/%s/"%(type)+str(headfilename)+endfile + + with open(f"{filename}", "wb") as buffer: + shutil.copyfileobj(audio.file, buffer) + + # Here you can process the audio file as needed + # For example, you might want to move it to a permanent location + # or perform some operations on it + #payload={"password":GetText2Voice.extractConfig(nameModel="SystemData",relPath=os.path.join(pwd,"conf/experiment_config.json"),dataOut="password"),"local":filename} + #A=requests.get("http://127.0.0.1:7870/voice2txtlocal", json=payload) + t=time.time() + return JSONResponse(content={ + "message": filename, + "time":time.time()-t + }, status_code=200) + + except Exception as e: + return JSONResponse(content={ + "message": f"There was an error uploading the file: {str(e)}" + }, status_code=500) + + finally: + audio.file.close() + +@app.get("/addaudiohtml") +def addaudiohtml(): + html=""" + +
+