reab5555 commited on
Commit
fee5ad2
·
verified ·
1 Parent(s): b90a67a

Update transcribe.py

Browse files
Files changed (1) hide show
  1. transcribe.py +8 -1
transcribe.py CHANGED
@@ -37,7 +37,14 @@ def transcribe(video_file, transcribe_to_text=True, transcribe_to_srt=True, targ
37
  temp_file_path = f"temp_audio_chunk_{i}.wav"
38
  audio_chunk.write_audiofile(temp_file_path, codec='pcm_s16le')
39
 
40
- sound_array = AudioFileClip(temp_file_path).to_soundarray(fps=16000)
 
 
 
 
 
 
 
41
  if sound_array.ndim > 1:
42
  sound_array = np.mean(sound_array, axis=1)
43
 
 
37
  temp_file_path = f"temp_audio_chunk_{i}.wav"
38
  audio_chunk.write_audiofile(temp_file_path, codec='pcm_s16le')
39
 
40
+
41
+ try:
42
+ sound_array = AudioFileClip(temp_file_path).to_soundarray(fps=16000, nbytes=1, quantize=True)
43
+ except Exception as e:
44
+ print(f"Error reading audio file: {e}")
45
+ continue # Skip this chunk if there's an error
46
+
47
+
48
  if sound_array.ndim > 1:
49
  sound_array = np.mean(sound_array, axis=1)
50