Dhrumit1314 commited on
Commit
389f9d1
1 Parent(s): 8aa894e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -56,31 +56,31 @@ def hello2():
56
  # Route for uploading video files
57
  @app.route('/upload_video', methods=['POST'])
58
  def upload_video():
59
- start_time = time.time()
60
- if 'video' not in request.files:
61
- return jsonify({'error': 'No video file found in the request'})
 
62
 
63
- video = request.files['video']
64
- if video.filename == '':
65
- return jsonify({'error': 'No selected video file'})
66
 
67
- if video.mimetype.split('/')[0] != 'video':
68
- return jsonify({'error': 'The file uploaded is not a video'})
69
 
70
- model_name = request.form.get('modelName')
71
- print("MODEL:", model_name)
72
 
73
- try:
74
  # Save the uploaded video to a temporary directory
75
  video_path = os.path.join(os.getcwd(), 'temp', secure_filename(video.filename))
76
  video.save(video_path)
77
 
78
- # Save the video file to Hugging Face Spaces
79
- video_file_id = hf_hub.upload(video_path, name=video.filename)
80
-
81
  # Transcribe audio from the uploaded video
82
  transcript = transcribe_audio(video_path)
83
 
 
 
 
84
  # Save the transcribed audio to a temporary WAV file
85
  audio_path = os.path.join(os.getcwd(), 'temp', 'transcribed_audio.wav')
86
  with open(audio_path, 'w') as audio_file:
 
56
  # Route for uploading video files
57
  @app.route('/upload_video', methods=['POST'])
58
  def upload_video():
59
+ try:
60
+ start_time = time.time()
61
+ if 'video' not in request.files:
62
+ return jsonify({'error': 'No video file found in the request'})
63
 
64
+ video = request.files['video']
65
+ if video.filename == '':
66
+ return jsonify({'error': 'No selected video file'})
67
 
68
+ if video.mimetype.split('/')[0] != 'video':
69
+ return jsonify({'error': 'The file uploaded is not a video'})
70
 
71
+ model_name = request.form.get('modelName')
72
+ print("MODEL:", model_name)
73
 
 
74
  # Save the uploaded video to a temporary directory
75
  video_path = os.path.join(os.getcwd(), 'temp', secure_filename(video.filename))
76
  video.save(video_path)
77
 
 
 
 
78
  # Transcribe audio from the uploaded video
79
  transcript = transcribe_audio(video_path)
80
 
81
+ # Save the video file to Hugging Face Spaces
82
+ video_file_id = hf_hub.upload(video_path, name=video.filename)
83
+
84
  # Save the transcribed audio to a temporary WAV file
85
  audio_path = os.path.join(os.getcwd(), 'temp', 'transcribed_audio.wav')
86
  with open(audio_path, 'w') as audio_file: