Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -9,31 +9,29 @@ from transformers import pipeline
|
|
9 |
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
|
11 |
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
temp = open("model/t.txt","r")
|
16 |
|
17 |
app = FastAPI()
|
18 |
|
19 |
-
# Define the directory to store uploaded files
|
20 |
-
UPLOAD_DIR = "/data"
|
21 |
|
22 |
-
|
23 |
-
def startup_event():
|
24 |
-
# Check and create the directory if it doesn't exist
|
25 |
-
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
26 |
-
print("created")
|
27 |
|
28 |
@app.get("/")
|
29 |
def read_root():
|
30 |
-
|
|
|
31 |
|
32 |
@app.post("/uploadfile/")
|
33 |
async def create_upload_file(file: UploadFile = File(...)):
|
34 |
try:
|
35 |
# Save the file with a specific name
|
36 |
-
file_path =
|
37 |
|
38 |
with open(file_path, "wb") as f:
|
39 |
f.write(file.file.read())
|
|
|
9 |
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
|
11 |
|
12 |
+
|
13 |
+
|
14 |
+
temp = open("model/t.txt","w")
|
15 |
+
temp.write("aaaaaaaaaaaaa")
|
16 |
+
temp.close()
|
17 |
|
18 |
temp = open("model/t.txt","r")
|
19 |
|
20 |
app = FastAPI()
|
21 |
|
|
|
|
|
22 |
|
23 |
+
|
|
|
|
|
|
|
|
|
24 |
|
25 |
@app.get("/")
|
26 |
def read_root():
|
27 |
+
output = pipe_flan("hi")
|
28 |
+
return {"message": str(output[0]["generated_text"])}
|
29 |
|
30 |
@app.post("/uploadfile/")
|
31 |
async def create_upload_file(file: UploadFile = File(...)):
|
32 |
try:
|
33 |
# Save the file with a specific name
|
34 |
+
file_path = "inputvoice.mp3"
|
35 |
|
36 |
with open(file_path, "wb") as f:
|
37 |
f.write(file.file.read())
|