Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,9 @@ import whisper
|
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
|
|
|
|
|
|
8 |
# Load the Whisper model
|
9 |
model = whisper.load_model("base")
|
10 |
|
@@ -38,8 +41,9 @@ def upload_video():
|
|
38 |
def extract_audio(video_path):
|
39 |
audio_path = os.path.splitext(video_path)[0] + ".wav"
|
40 |
try:
|
41 |
-
|
42 |
-
|
|
|
43 |
except Exception as e:
|
44 |
raise RuntimeError(f"Error extracting audio: {e}")
|
45 |
return audio_path
|
|
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
8 |
+
# Configure the maximum content length for uploads (500 MB)
|
9 |
+
app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024 * 500 # 500 MB limit
|
10 |
+
|
11 |
# Load the Whisper model
|
12 |
model = whisper.load_model("base")
|
13 |
|
|
|
41 |
def extract_audio(video_path):
|
42 |
audio_path = os.path.splitext(video_path)[0] + ".wav"
|
43 |
try:
|
44 |
+
# Use a temporary file to reduce the load on memory
|
45 |
+
with VideoFileClip(video_path) as video:
|
46 |
+
video.audio.write_audiofile(audio_path)
|
47 |
except Exception as e:
|
48 |
raise RuntimeError(f"Error extracting audio: {e}")
|
49 |
return audio_path
|