Zeph27 commited on
Commit
60e801c
β€’
1 Parent(s): 1f61ce9
Files changed (2) hide show
  1. app.py +3 -3
  2. packages.txt +1 -0
app.py CHANGED
@@ -56,9 +56,9 @@ def encode_video(video_path):
56
  return video
57
 
58
  def extract_audio(video_path):
59
- video = mp.VideoFileClip(video_path)
60
  audio_path = "temp_audio.wav"
61
- video.audio.write_audiofile(audio_path)
62
  return audio_path
63
 
64
  def transcribe_audio(audio_file):
@@ -68,7 +68,7 @@ def transcribe_audio(audio_file):
68
  inputs = ffmpeg_read(inputs, asr_pipeline.feature_extractor.sampling_rate)
69
  inputs = {"array": inputs, "sampling_rate": asr_pipeline.feature_extractor.sampling_rate}
70
 
71
- transcription = asr_pipeline(inputs, batch_size=8, generate_kwargs={"task": "transcribe"}, return_timestamps=False)["text"]
72
  return transcription
73
 
74
  @spaces.GPU
 
56
  return video
57
 
58
  def extract_audio(video_path):
59
+ import subprocess
60
  audio_path = "temp_audio.wav"
61
+ subprocess.call(['ffmpeg', '-i', video_path, '-ab', '160k', '-ac', '2', '-ar', '44100', '-vn', audio_path])
62
  return audio_path
63
 
64
  def transcribe_audio(audio_file):
 
68
  inputs = ffmpeg_read(inputs, asr_pipeline.feature_extractor.sampling_rate)
69
  inputs = {"array": inputs, "sampling_rate": asr_pipeline.feature_extractor.sampling_rate}
70
 
71
+ transcription = asr_pipeline(inputs, batch_size=8, generate_kwargs={"task": "transcribe"}, return_timestamps=True)["text"]
72
  return transcription
73
 
74
  @spaces.GPU
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg