Explorar el Código

fix: tts voice base url

zhayujie hace 2 años
padre
commit
e5ba26febe
Se han modificado 2 ficheros con 5 adiciones y 2 borrados
  1. 3 1
      bot/linkai/link_ai_bot.py
  2. 2 1
      voice/openai/openai_voice.py

+ 3 - 1
bot/linkai/link_ai_bot.py

@@ -94,7 +94,7 @@ class LinkAIBot(Bot):
             file_id = context.kwargs.get("file_id")
             if file_id:
                 body["file_id"] = file_id
-            logger.info(f"[LINKAI] query={query}, app_code={app_code}, mode={body.get('model')}, file_id={file_id}")
+            logger.info(f"[LINKAI] query={query}, app_code={app_code}, model={body.get('model')}, file_id={file_id}")
             headers = {"Authorization": "Bearer " + linkai_api_key}
 
             # do http request
@@ -120,6 +120,8 @@ class LinkAIBot(Bot):
                 if response["choices"][0].get("img_urls"):
                     thread = threading.Thread(target=self._send_image, args=(context.get("channel"), context, response["choices"][0].get("img_urls")))
                     thread.start()
+                    if response["choices"][0].get("text_content"):
+                        reply_content = response["choices"][0].get("text_content")
                 return Reply(ReplyType.TEXT, reply_content)
 
             else:

+ 2 - 1
voice/openai/openai_voice.py

@@ -33,7 +33,8 @@ class OpenaiVoice(Voice):
 
     def textToVoice(self, text):
         try:
-            url = 'https://api.openai.com/v1/audio/speech'
+            api_base = conf().get("open_ai_api_base") or "https://api.openai.com/v1"
+            url = f'{api_base}/audio/speech'
             headers = {
                 'Authorization': 'Bearer ' + conf().get("open_ai_api_key"),
                 'Content-Type': 'application/json'