-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (27 loc) · 1004 Bytes
/
main.py
File metadata and controls
31 lines (27 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json
from flask import Flask, request, jsonify, Response
import os
from speech import speech_module
from cut import cut_module
from discription import discription_module
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False
@app.route('/audio_description', methods=['POST'])
def send_audio_description():
video_name = request.json['video_name']
os.chdir('/home/cool/videos/')
filename, _ = os.path.splitext(video_name)
if os.path.isfile(filename + '.json'):
with open(filename + '.json', encoding='utf-8') as f:
data = json.load(f)
return data
segments = speech_module.main(video_name)
frames = cut_module.main(video_name, segments)
print(segments)
disc = discription_module.predict_step(frames)
print(disc)
with open(f"{filename}.json", "w", encoding="utf-8") as file:
json.dump(disc, file, ensure_ascii=False)
return disc
if __name__ == '__main__':
app.run('0.0.0.0')