資源簡介
為了實現(xiàn)Python版本的訊飛語音合成,官方只給出了C++版本的實現(xiàn),于是我自己封裝實現(xiàn)Python版本TTS部分。
代碼片段和文件信息
import?hashlib
import?ctypes
import?os
import?time
from?collections?import?OrderedDict
def?check_sum(apikey?curtime?param?httpbody):
????‘‘‘
????計算訊飛服務(wù)授權(quán)的MD5校驗,見:http://aiui.xfyun.cn/help/devDoc#3
????example:?check_sum(‘a(chǎn)bcd1234‘‘1502607694‘‘eyJzY2VuZSI6Im1haW4ifQ==‘‘text=5LuK5aSp5pif5pyf5Yeg‘)
????:param?apikey:?str?訊飛開放平臺注冊申請應(yīng)用的應(yīng)用ID(APPID)
????:param?curtime:?str?當(dāng)前UTC時間戳,從1970年1月1日0點0?分0?秒開始到現(xiàn)在的秒數(shù)(String)
????:param?param:?str?base64編碼的json,見接口詳細(xì)說明
????:param?httpbody:?str內(nèi)容
????:return:?str?md5的32位編碼
????‘‘‘
????temp?=?‘%s%s%s%s‘?%?(apikey?curtime?param?httpbody)
????checkstring?=?temp.encode(‘utf-8‘)
????md5?=?hashlib.md5()
????md5.update(checkstring)
????checkmd5?=?md5.hexdigest()
????return?checkmd5
def?load_dll_msc(dllpath):
??
評論
共有 條評論