def fn_extract_wav(piece):
"""Save the base64 encoded wav data in this email piece and
return the file path and name as a string
"""
glog('Extracting wav from piece')
# parse this piece of the email text to merge the
# base64 encoded string into one line and then
# decode the string into binary data
capture = False
lines = []
index = 0
for line in piece.split('\n'):
if line.strip() == "":
capture = True
if capture == True:
lines.append(line.strip())
index = index + 1
b64_data = ''.join(lines)
data = base64.b64decode(b64_data)
rs_string = random_string(20)
if not os.path.exists(GLV_TMP_PATH_TO_SAVE_VOICEMAIL):
os.makedirs(GLV_TMP_PATH_TO_SAVE_VOICEMAIL)
rs_path = GLV_TMP_PATH_TO_SAVE_VOICEMAIL + rs_string + '.wav'
glog("save wav file to " + rs_path)
with open(rs_path, 'wb') as f:
f.write(data)
# return temporary file path and name
return rs_path
vrmilter.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录