강수빈

hz 계산 웹서버 코드 수정

......@@ -13,13 +13,21 @@ def maiddn():
def upload_file():
params = json.loads(request.get_data(), encoding='utf-8')
data=params['datas']
timeData=params['timeData']
print(len(data))
make_wav_file(data)
print(timeData)
make_wav_file(data, timeData)
return send_file("test.wav", attachment_filename='test.wav', as_attachment=True)
def make_wav_file(data):
def make_wav_file(data, timeData):
print('convert is loading')
print(len(data))
print(timeData)
print(len(data) / timeData)
hz = int(len(data) / timeData)
print("hz=")
print(hz)
eng = matlab.engine.start_matlab()
l1=[]
for t in data:
......@@ -29,8 +37,9 @@ def make_wav_file(data):
print(t)
l2 = [n/10000 for n in l1]
data = matlab.double(l2)
filename = 'test.wav'
eng.audiowrite(filename, data, 1000, nargout=0)
eng.audiowrite(filename, data, hz, nargout=0)
eng.quit()
@app.route('/combine', methods=['POST'])
......@@ -40,7 +49,6 @@ def combineMp4Wav():
print("error")
return "error"
file = request.files['Video']
print(file)
file.save("video.mp4")
os.system("ffmpeg -i video.mp4 -i test.wav -c:v copy -c:a aac -strict experimental -vcodec libx264 -map 0:v:0 -map 1:a:0 -y output.mp4")
return "Success"
......
No preview for this file type