tangtang369 最近的时间轴更新
tangtang369

tangtang369

V2EX 第 392926 号会员,加入于 2019-03-17 18:27:02 +08:00
今日活跃度排名 29117
根据 tangtang369 的设置,主题列表被隐藏
二手交易 相关的信息,包括已关闭的交易,不会被隐藏
tangtang369 最近回复了
看你经验有点像纯调用 API 的,其实还是偏后端的那种,这种其实和 ai 不咋搭边
214 天前
回复了 jiaokuniu 创建的主题 计算机 有没有必要等 Zen5 的迷你主机?
amd 真的有 ai 生态吗 认清现实
后端 python 或者 go 工作好像很多的
@drymonfidelia #25 你是 windows 吗 这个我 mac 和 linux 测了没啥问题
227 天前
回复了 hello267015 创建的主题 分享发现 曝光滴滴的骚操作
是不是自动把紧急联系人给你强制关联了支付
227 天前
回复了 Grocker 创建的主题 程序员 分辨多个用户之间是否是分身的算法?
建议放弃,以前不学,现在是很难学的进去的,或者是说自制力不行
这样好像可以删除掉
```
from flask import Flask, request, send_file, abort,after_this_request
import ffmpeg
import os
import tempfile
import time

app = Flask(__name__)

@app.route('/audio_appledevices/<name>.m4a', methods=['GET'])
def convert_audio(name):
ogg_path = f'./audio/{name}.ogg'
if not os.path.exists(ogg_path):
abort(404)
with tempfile.NamedTemporaryFile(delete=False, suffix='.m4a') as temp_file:
m4a_path = temp_file.name
try:
ffmpeg.input(ogg_path).output(m4a_path, codec='alac').run(overwrite_output=True)
response = send_file(m4a_path, as_attachment=True, download_name=f'{name}.m4a', mimetype='audio/mp4')
print("run m4a_path",m4a_path)

@after_this_request
def cleanup(response):
print("run cleanup")
time.sleep(1)
if os.path.exists(m4a_path):
os.remove(m4a_path)
return response
return response
except ffmpeg.Error as e:
abort(500)


if __name__ == '__main__':
app.run(host='127.0.0.1', port=3389)
```
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   976 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 9ms · UTC 22:04 · PVG 06:04 · LAX 15:04 · JFK 18:04
Developed with CodeLauncher
♥ Do have faith in what you're doing.