bichnhan2701 commited on
Commit
bf0fd01
·
1 Parent(s): fe80760

Add chunks in JSONResponse for URL transcribe

Browse files
Files changed (1) hide show
  1. app/main.py +7 -1
app/main.py CHANGED
@@ -95,8 +95,14 @@ async def transcribe_url(payload: dict):
95
  if MODEL is None:
96
  MODEL = load_model(chunk_length_s=30)
97
  text = transcribe_file(MODEL, tmp_wav, max_chunk_length=30.0, overlap_s=5.0)
 
98
  info2 = get_audio_info(tmp_wav) or {}
99
- return JSONResponse({"text": text, "duration": info2.get("duration"), "sample_rate": info2.get("samplerate")})
 
 
 
 
 
100
  except HTTPException:
101
  raise
102
  except Exception as e:
 
95
  if MODEL is None:
96
  MODEL = load_model(chunk_length_s=30)
97
  text = transcribe_file(MODEL, tmp_wav, max_chunk_length=30.0, overlap_s=5.0)
98
+ chunks = transcribe_file_chunks(MODEL, tmp_wav, max_chunk_length=30.0, overlap_s=5.0)
99
  info2 = get_audio_info(tmp_wav) or {}
100
+ return JSONResponse({
101
+ "text": text,
102
+ "duration": info2.get("duration"),
103
+ "sample_rate": info2.get("samplerate"),
104
+ "chunks": chunks
105
+ })
106
  except HTTPException:
107
  raise
108
  except Exception as e: