1818from voice .voice import Voice
1919from voice .ali .ali_api import AliyunTokenGenerator
2020from voice .ali .ali_api import text_to_speech_aliyun
21+ from config import conf
2122
2223
2324class AliVoice (Voice ):
@@ -32,10 +33,11 @@ def __init__(self):
3233 config = json .load (fr )
3334 self .token = None
3435 self .token_expire_time = 0
36+ # 默认复用阿里云千问的 access_key 和 access_secret
3537 self .api_url = config .get ("api_url" )
36- self .appkey = config .get ("appkey " )
37- self .access_key_id = config .get ("access_key_id" )
38- self .access_key_secret = config .get ("access_key_secret" )
38+ self .app_key = config .get ("app_key " )
39+ self .access_key_id = conf (). get ( "qwen_access_key_id" ) or config .get ("access_key_id" )
40+ self .access_key_secret = conf (). get ( "qwen_access_key_secret" ) or config .get ("access_key_secret" )
3941 except Exception as e :
4042 logger .warn ("AliVoice init failed: %s, ignore " % e )
4143
@@ -51,7 +53,7 @@ def textToVoice(self, text):
5153 r'äöüÄÖÜáéíóúÁÉÍÓÚàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛçÇñÑ,。!?,.]' , '' , text )
5254 # 提取有效的token
5355 token_id = self .get_valid_token ()
54- fileName = text_to_speech_aliyun (self .api_url , text , self .appkey , token_id )
56+ fileName = text_to_speech_aliyun (self .api_url , text , self .app_key , token_id )
5557 if fileName :
5658 logger .info ("[Ali] textToVoice text={} voice file name={}" .format (text , fileName ))
5759 reply = Reply (ReplyType .VOICE , fileName )
0 commit comments