|
@@ -63,6 +63,7 @@ class MyAudioMediaPort(pj.AudioMediaPort):
|
|
|
self.call = call
|
|
|
self.aud_media = aud_media
|
|
|
self.asr = asr
|
|
|
+ self.first = True
|
|
|
|
|
|
self.user_asr_texts = []
|
|
|
|
|
@@ -73,9 +74,12 @@ class MyAudioMediaPort(pj.AudioMediaPort):
|
|
|
|
|
|
def onFrameReceived(self, frame):
|
|
|
# self.wav.writeframes(bytes(frame.buf))
|
|
|
- # print("Received audio frame:", frame.buf, frame.size)
|
|
|
if self.asr: # 如果ASR实例存在,则发送音频数据
|
|
|
+ if self.first:
|
|
|
+ self.first = False
|
|
|
+ self.logger.info("Received audio frame: %s %s", frame.buf, frame.size)
|
|
|
self.asr.send_audio(frame.buf)
|
|
|
+
|
|
|
try:
|
|
|
asr_text = self.get_asr_text()
|
|
|
play_complete = self.call.is_play_complete()
|