chompionsawelo commited on
Commit
e788c39
·
1 Parent(s): f8597f4
Files changed (1) hide show
  1. transcribe.py +6 -4
transcribe.py CHANGED
@@ -12,6 +12,7 @@ model = WhisperModel("medium", device="cuda", compute_type="int8_float16")
12
  def start_transcribe(progress):
13
  _, speaker_groups = load_groups_json()
14
 
 
15
  for speaker, _ in zip(speaker_groups, progress.tqdm(speaker_groups, desc="Processing diarization")):
16
  # Transcribe and save temp file
17
  audiof = f"{speaker}.wav"
@@ -26,10 +27,8 @@ def start_transcribe(progress):
26
  end = timeStr(segment.end)
27
  name = str(speaker)[:10]
28
  text = segment.text
29
- subtitle_txt = f"{len(subtitle_txt) + 1}\n{start} --> {end}\n[{name}] {text}\n\n"
30
- # Appending subtitle txt for each segment
31
- with open("subtitle.srt", "a") as file:
32
- file.writelines(subtitle_txt)
33
  # Appending text for each segment to print
34
  text_list_to_print.append(text)
35
 
@@ -40,6 +39,9 @@ def start_transcribe(progress):
40
  with open("transcribe.txt", "a") as file:
41
  file.write(f"[{name}] {text}\n")
42
 
 
 
 
43
  return ["transcribe.txt", "subtitle.srt"]
44
 
45
 
 
12
  def start_transcribe(progress):
13
  _, speaker_groups = load_groups_json()
14
 
15
+ subtitle_txt = []
16
  for speaker, _ in zip(speaker_groups, progress.tqdm(speaker_groups, desc="Processing diarization")):
17
  # Transcribe and save temp file
18
  audiof = f"{speaker}.wav"
 
27
  end = timeStr(segment.end)
28
  name = str(speaker)[:10]
29
  text = segment.text
30
+ subtitle_txt.append(
31
+ f"{len(subtitle_txt) + 1}\n{start} --> {end}\n[{name}] {text}\n\n")
 
 
32
  # Appending text for each segment to print
33
  text_list_to_print.append(text)
34
 
 
39
  with open("transcribe.txt", "a") as file:
40
  file.write(f"[{name}] {text}\n")
41
 
42
+ # Appending subtitle txt for each segment
43
+ with open("subtitle.srt", "w") as file:
44
+ file.writelines(subtitle_txt)
45
  return ["transcribe.txt", "subtitle.srt"]
46
 
47