Dhrumit1314 commited on
Commit
d1cc910
1 Parent(s): 82c0891

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -40
app.py CHANGED
@@ -48,57 +48,57 @@ def hello():
48
  # h = "<h1>This is the backend deployed web page created by NotivAI!!</h1>"
49
  return h
50
 
51
- @app.route('/get_tested',methods=['GET'])
52
- def hello2():
53
- h = "<h1>Hello this is testing!!</h1>"
54
- return h
55
 
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
- video = request.files['video']
63
- if video.mimetype.split('/')[0] != 'video':
64
- return jsonify({'error': 'The file uploaded is not a video'})
65
 
66
- model_name = request.form.get('modelName')
67
- print("MODEL:", model_name)
68
 
69
- video_path = os.path.join(os.getcwd(), secure_filename(video.filename))
70
- video.save(video_path)
71
 
72
- # Initialize HfApi and HfFolder
73
- api = HfApi()
74
- folder = HfFolder()
75
 
76
- token = folder.get_token()
77
- namespace = "Dhrumit1314/videoUpload"
78
 
79
- # Upload the video file
80
- video_file_id = api.upload_file(
81
- token=token,
82
- path_or_fileobj=video_path,
83
- repo_id=namespace,
84
- path_in_repo=video.filename
85
- )
86
 
87
- transcript = transcribe_audio(video_path)
88
 
89
- summary = ""
90
- if model_name == 'T5':
91
- summary = summarize_text_t5(transcript)
92
- elif model_name == 'BART':
93
- summary = summarize_text_bart(transcript)
94
- else:
95
- summary = summarizer(transcript)
96
 
97
- end_time = time.time()
98
- elapsed_time = end_time - start_time
99
- print(f"Video saved successfully. Time taken: {elapsed_time} seconds")
100
 
101
- return jsonify({'message': 'successful', 'transcript': transcript, 'summary': summary, 'modelName': model_name, 'videoFileId': video_file_id})
102
 
103
 
104
  # def upload_video():
 
48
  # h = "<h1>This is the backend deployed web page created by NotivAI!!</h1>"
49
  return h
50
 
51
+ # @app.route('/get_tested',methods=['GET'])
52
+ # def hello2():
53
+ # h = "<h1>Hello this is testing!!</h1>"
54
+ # return h
55
 
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
+ # video = request.files['video']
63
+ # if video.mimetype.split('/')[0] != 'video':
64
+ # return jsonify({'error': 'The file uploaded is not a video'})
65
 
66
+ # model_name = request.form.get('modelName')
67
+ # print("MODEL:", model_name)
68
 
69
+ # video_path = os.path.join(os.getcwd(), secure_filename(video.filename))
70
+ # video.save(video_path)
71
 
72
+ # # Initialize HfApi and HfFolder
73
+ # api = HfApi()
74
+ # folder = HfFolder()
75
 
76
+ # token = folder.get_token()
77
+ # namespace = "Dhrumit1314/videoUpload"
78
 
79
+ # # Upload the video file
80
+ # video_file_id = api.upload_file(
81
+ # token=token,
82
+ # path_or_fileobj=video_path,
83
+ # repo_id=namespace,
84
+ # path_in_repo=video.filename
85
+ # )
86
 
87
+ # transcript = transcribe_audio(video_path)
88
 
89
+ # summary = ""
90
+ # if model_name == 'T5':
91
+ # summary = summarize_text_t5(transcript)
92
+ # elif model_name == 'BART':
93
+ # summary = summarize_text_bart(transcript)
94
+ # else:
95
+ # summary = summarizer(transcript)
96
 
97
+ # end_time = time.time()
98
+ # elapsed_time = end_time - start_time
99
+ # print(f"Video saved successfully. Time taken: {elapsed_time} seconds")
100
 
101
+ # return jsonify({'message': 'successful', 'transcript': transcript, 'summary': summary, 'modelName': model_name, 'videoFileId': video_file_id})
102
 
103
 
104
  # def upload_video():