Pepguy commited on
Commit
caed07e
·
verified ·
1 Parent(s): 90d1287

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -34,7 +34,15 @@ async def process(req: VideoJsonRequest):
34
  subprocess.run(["ffmpeg", "-y",
35
  "-loglevel", "error",
36
  "-i", v_p, "-vn", "-acodec", "pcm_s16le", "-ar", "16000", "-ac", "1", a_p])
37
- txt = whisper_model.transcribe(a_p)["text"].strip()
 
 
 
 
 
 
 
 
38
  f_names = sorted([f"{tmp}/{f}" for f in os.listdir(tmp) if f.startswith("f_")])
39
  imgs = [to_b64(f) for f in f_names]
40
  print("-------------------")
 
34
  subprocess.run(["ffmpeg", "-y",
35
  "-loglevel", "error",
36
  "-i", v_p, "-vn", "-acodec", "pcm_s16le", "-ar", "16000", "-ac", "1", a_p])
37
+ #txt = whisper_model.transcribe(a_p)["text"].strip()
38
+ result = whisper_model.transcribe(a_p)
39
+
40
+ lines = [
41
+ f"[{s['start']:.2f}] {s['text'].strip()}"
42
+ for s in result["segments"]
43
+ ]
44
+
45
+ txt = "\n".join(lines)
46
  f_names = sorted([f"{tmp}/{f}" for f in os.listdir(tmp) if f.startswith("f_")])
47
  imgs = [to_b64(f) for f in f_names]
48
  print("-------------------")