karthi311 commited on
Commit
3a476f1
·
verified ·
1 Parent(s): 0603d42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -31,9 +31,16 @@ def convert_mp4_to_mp3(mp4_path, mp3_path):
31
  # Transcribe audio
32
  def transcribe_audio(audio_path):
33
  try:
34
- inputs = ffmpeg_read(audio_path, whisper_pipeline.feature_extractor.sampling_rate)
 
 
 
 
 
35
  inputs = {"array": inputs, "sampling_rate": whisper_pipeline.feature_extractor.sampling_rate}
36
- result = whisper_pipeline(inputs, batch_size=BATCH_SIZE, return_timestamps=False)
 
 
37
  return result["text"]
38
  except Exception as e:
39
  return f"Error during transcription: {e}"
 
31
  # Transcribe audio
32
  def transcribe_audio(audio_path):
33
  try:
34
+ # Ensure the audio file is read correctly in bytes format
35
+ with open(audio_path, "rb") as audio_file:
36
+ audio_data = audio_file.read() # Read the file as bytes
37
+
38
+ # Process the audio file for transcription
39
+ inputs = ffmpeg_read(audio_data, whisper_pipeline.feature_extractor.sampling_rate)
40
  inputs = {"array": inputs, "sampling_rate": whisper_pipeline.feature_extractor.sampling_rate}
41
+
42
+ # Run the transcription pipeline
43
+ result = whisper_pipeline(inputs, batch_size=8, return_timestamps=False)
44
  return result["text"]
45
  except Exception as e:
46
  return f"Error during transcription: {e}"