Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
|
3 |
+
from fastapi import FastAPI, File, UploadFile
|
4 |
+
from llava import main
|
5 |
+
import shutil
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
@app.post("/process_audio/")
|
10 |
+
async def process_audio(file: UploadFile = File(...)):
|
11 |
+
# Save uploaded file to a temporary location
|
12 |
+
file_path = f"temp_{file.filename}"
|
13 |
+
with open(file_path, "wb") as buffer:
|
14 |
+
shutil.copyfileobj(file.file, buffer)
|
15 |
+
|
16 |
+
# Call the main function from llava.py to process the file
|
17 |
+
response_audio = main(file_path)
|
18 |
+
|
19 |
+
return {"response_audio": response_audio}
|