Mpavan45 commited on
Commit
fbfa389
·
verified ·
1 Parent(s): 00ba7a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -91,13 +91,22 @@ from chromadb.utils import embedding_functions
91
  from chromadb import Client
92
  from chromadb.config import Settings
93
 
94
- def extract_audio(file_path):
95
  """Extracts audio from video or handles audio file directly."""
96
  audio_path = "temp_audio.wav"
97
- if file_path.endswith(('.mp4', '.mkv')):
98
- ffmpeg.input(file_path).output(audio_path).run(overwrite_output=True)
 
 
 
 
 
 
99
  else:
100
- audio_path = file_path
 
 
 
101
  return audio_path
102
 
103
  def transcribe_audio(audio_path):
 
91
  from chromadb import Client
92
  from chromadb.config import Settings
93
 
94
+ def extract_audio(file):
95
  """Extracts audio from video or handles audio file directly."""
96
  audio_path = "temp_audio.wav"
97
+
98
+ # Use FFmpeg to extract audio from the uploaded buffer
99
+ if file.name.endswith(('.mp4', '.mkv')):
100
+ with open("temp_video.mp4", "wb") as f:
101
+ f.write(file.getvalue())
102
+
103
+ # Extract audio using the temp file
104
+ ffmpeg.input("temp_video.mp4").output(audio_path).run(overwrite_output=True)
105
  else:
106
+ # Handle audio files directly
107
+ with open(audio_path, "wb") as f:
108
+ f.write(file.getvalue())
109
+
110
  return audio_path
111
 
112
  def transcribe_audio(audio_path):