Explorar o código

讯飞asr测试,debug

Davidliu hai 1 mes
pai
achega
2e7594eef9
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      src/core/voip/asr.py

+ 4 - 0
src/core/voip/asr.py

@@ -175,6 +175,7 @@ class TestSt:
 
 # 讯飞ASR实时转写
 class XfAsr:
+
     def __init__(self, tid, logger, message_receiver=None):
         import hashlib
         import hmac
@@ -203,11 +204,13 @@ class XfAsr:
         signa = hmac.new(apiKey, baseString, hashlib.sha1).digest()
         signa = base64.b64encode(signa)
         signa = str(signa, 'utf-8')
+
         self.end_tag = "{\"end\": true}"
         self.tid = tid
         self.logger = logger
         self.message_receiver = message_receiver
         self.ws = create_connection(base_url + "?appid=" + app_id + "&ts=" + ts + "&signa=" + quote(signa))
+        self.logger.info(f"xunfei.Asr: ws.connected:{self.ws.connected}")
         self.trecv = threading.Thread(target=self.recv)
 
     def start(self):
@@ -241,6 +244,7 @@ class XfAsr:
 
     def recv(self):
         try:
+            self.logger.info(f"xunfei.Asr.recv: ws.connected:{self.ws.connected}")
             while self.ws.connected:
                 result = str(self.ws.recv())
                 if len(result) == 0: