Browse Source

讯飞asr测试,debug

Davidliu 1 month ago
parent
commit
3dd746ee55
3 changed files with 6 additions and 6 deletions
  1. 1 1
      src/core/voip/asr.py
  2. 4 4
      src/core/voip/bot.py
  3. 1 1
      src/core/voip/constant.py

+ 1 - 1
src/core/voip/asr.py

@@ -269,7 +269,7 @@ class XfAsr:
     #     print("send end tag success")
 
     def send_audio(self, chunk):
-        # self.logger.info('xunfei.Asr.send_audio:chunk:%s', chunk)
+        self.logger.info('xunfei.Asr.send_audio:chunk:%s, %s', len(chunk), chunk)
         if self.ws:
             self.ws.send(chunk)
 

+ 4 - 4
src/core/voip/bot.py

@@ -80,9 +80,9 @@ class MyAudioMediaPort(pj.AudioMediaPort):
     def onFrameReceived(self, frame):
         # self.wav.writeframes(bytes(frame.buf))
         if self.asr:  # 如果ASR实例存在,则发送音频数据
-            # if self.first:
-            #     self.first = False
-            self.call.logger.warn("Received audio frame: %s, %s, %s", self.call.session_id,frame.buf,frame.size)
+            if self.first:
+                self.first = False
+                self.call.logger.warn("Received audio frame: %s, %s, %s", self.call.session_id,frame.buf,frame.size)
             self.asr.send_audio(frame.buf)
 
         try:
@@ -616,7 +616,7 @@ class BotAgent:
             media_cfg.noVad = True  # Disable Voice Activity Detection if needed
             media_cfg.clockRate = 16000
             media_cfg.channelCount = 1
-            media_cfg.audioFramePtime = 40
+            # media_cfg.audioFramePtime = 40
             # media_cfg.ptime = 40
             # media_cfg.clockRate = 8000
             self.ep.medConfig = media_cfg  # Apply media config to endpoint

+ 1 - 1
src/core/voip/constant.py

@@ -23,7 +23,7 @@ def build_audio_format():
     fmt.bitsPerSample = 16  # 每个采样的位数
     # fmt.clockRate = 8000  # 采样率
     fmt.clockRate = 16000  # 采样率
-    fmt.frameTimeUsec = 40000
+    fmt.frameTimeUsec = 40000  #微秒
     # fmt.clockRate = 16000  # 采样率
     # fmt.frameTimeUsec = 20000
     return fmt