AbirMessaoudi ssolito commited on
Commit
790d7cc
·
verified ·
1 Parent(s): 24a2822

Update whisper.py (#14)

Browse files

- Update whisper.py (beabd7ce92d057ea91e8993afddf9e989f891719)


Co-authored-by: Sarah Solito <ssolito@users.noreply.huggingface.co>

Files changed (1) hide show
  1. whisper.py +3 -2
whisper.py CHANGED
@@ -134,6 +134,8 @@ def generate(audio_path, use_v2):
134
  output = ""
135
  for start, end, speaker, text in merged_transcript:
136
  output += f"[{speaker}]: {text}\n"
 
 
137
 
138
  else:
139
  audio = AudioSegment.from_wav(audio_path)
@@ -144,8 +146,7 @@ def generate(audio_path, use_v2):
144
  audio.export(temp_mono_path, format="wav")
145
  audio_path = temp_mono_path
146
  output = transcribe_pipeline(format_audio(audio_path), task)
147
-
148
- clean_output = post_process_transcription(output, max_repeats=1) #check
149
 
150
  if temp_mono_path and os.path.exists(temp_mono_path):
151
  os.remove(temp_mono_path)
 
134
  output = ""
135
  for start, end, speaker, text in merged_transcript:
136
  output += f"[{speaker}]: {text}\n"
137
+
138
+ clean_output = output.strip()
139
 
140
  else:
141
  audio = AudioSegment.from_wav(audio_path)
 
146
  audio.export(temp_mono_path, format="wav")
147
  audio_path = temp_mono_path
148
  output = transcribe_pipeline(format_audio(audio_path), task)
149
+ clean_output = post_process_transcription(output)
 
150
 
151
  if temp_mono_path and os.path.exists(temp_mono_path):
152
  os.remove(temp_mono_path)