reab5555 commited on
Commit
62a24bb
·
verified ·
1 Parent(s): fc8fbe9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -26,7 +26,6 @@ def transcribe(video_file, transcribe_to_text, transcribe_to_srt, language):
26
  return_timestamps=True,
27
  torch_dtype=torch_dtype,
28
  device=device,
29
- generate_kwargs={"language": language}
30
  )
31
 
32
  # Handle the video file input
@@ -46,7 +45,7 @@ def transcribe(video_file, transcribe_to_text, transcribe_to_srt, language):
46
  temp_file_path = f"temp_audio_{i}.wav"
47
  audio_chunk.write_audiofile(temp_file_path, codec='pcm_s16le')
48
  with open(temp_file_path, "rb") as temp_file:
49
- result = pipe(temp_file_path)
50
  transcription_txt += result["text"]
51
  if transcribe_to_srt:
52
  for chunk in result["chunks"]:
@@ -57,9 +56,10 @@ def transcribe(video_file, transcribe_to_text, transcribe_to_srt, language):
57
  "text": chunk["text"]
58
  })
59
  os.remove(temp_file_path)
60
- yield f"Progress: {int(((i + 1) / n_chunks) * 100)}%"
61
-
62
  output = ""
 
63
  if transcribe_to_text:
64
  output += "Text Transcription:\n" + transcription_txt + "\n\n"
65
  if transcribe_to_srt:
@@ -77,7 +77,7 @@ def transcribe(video_file, transcribe_to_text, transcribe_to_srt, language):
77
 
78
  output += f"\nSRT file saved as: {srt_file_path}"
79
 
80
- yield output, srt_file_path if transcribe_to_srt else None
81
 
82
  def format_time(seconds):
83
  m, s = divmod(seconds, 60)
 
26
  return_timestamps=True,
27
  torch_dtype=torch_dtype,
28
  device=device,
 
29
  )
30
 
31
  # Handle the video file input
 
45
  temp_file_path = f"temp_audio_{i}.wav"
46
  audio_chunk.write_audiofile(temp_file_path, codec='pcm_s16le')
47
  with open(temp_file_path, "rb") as temp_file:
48
+ result = pipe(temp_file_path, generate_kwargs={"language": language})
49
  transcription_txt += result["text"]
50
  if transcribe_to_srt:
51
  for chunk in result["chunks"]:
 
56
  "text": chunk["text"]
57
  })
58
  os.remove(temp_file_path)
59
+ yield f"Progress: {int(((i + 1) / n_chunks) * 100)}%", None
60
+
61
  output = ""
62
+ srt_file_path = None
63
  if transcribe_to_text:
64
  output += "Text Transcription:\n" + transcription_txt + "\n\n"
65
  if transcribe_to_srt:
 
77
 
78
  output += f"\nSRT file saved as: {srt_file_path}"
79
 
80
+ yield output, srt_file_path
81
 
82
  def format_time(seconds):
83
  m, s = divmod(seconds, 60)