MariaKaiser commited on
Commit
ff6cba5
·
verified ·
1 Parent(s): 046f242

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -3
app.py CHANGED
@@ -477,9 +477,27 @@ async def process_story(story: StoryCreationDTO, background_tasks: BackgroundTas
477
 
478
  #-----------------------Results Get End Point ______________________________________
479
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  @app.get("/tts/results/{task_id}")
481
  async def get_results(task_id: str):
482
-
483
  if task_id not in tasks:
484
  return {"status": "not_found"}
485
 
@@ -491,10 +509,16 @@ async def get_results(task_id: str):
491
  if task["status"] == "failed":
492
  return {
493
  "status": "failed",
494
- "error": task["error"]
495
  }
496
 
497
- return task["result"]
 
 
 
 
 
 
498
 
499
  #----------------------------Test End Point to test tts inference------------------------------------
500
 
 
477
 
478
  #-----------------------Results Get End Point ______________________________________
479
 
480
+ # @app.get("/tts/results/{task_id}")
481
+ # async def get_results(task_id: str):
482
+
483
+ # if task_id not in tasks:
484
+ # return {"status": "not_found"}
485
+
486
+ # task = tasks[task_id]
487
+
488
+ # if task["status"] == "processing":
489
+ # return {"status": "processing"}
490
+
491
+ # if task["status"] == "failed":
492
+ # return {
493
+ # "status": "failed",
494
+ # "error": task["error"]
495
+ # }
496
+
497
+ # return task["result"]
498
+
499
  @app.get("/tts/results/{task_id}")
500
  async def get_results(task_id: str):
 
501
  if task_id not in tasks:
502
  return {"status": "not_found"}
503
 
 
509
  if task["status"] == "failed":
510
  return {
511
  "status": "failed",
512
+ "error": task.get("error", "Unknown error")
513
  }
514
 
515
+ # Ensure result exists and has all required fields
516
+ result = task.get("result")
517
+ if result and all(k in result for k in ("fileName", "duration", "audioBase64")):
518
+ return {"status": "completed", **result}
519
+ else:
520
+ # If result is missing fields, mark as still processing
521
+ return {"status": "processing"}
522
 
523
  #----------------------------Test End Point to test tts inference------------------------------------
524