This commit is contained in:
yumoqing 2024-09-18 16:06:41 +08:00
parent 54c9b4c14f
commit 2d7705a8cf

View File

@ -1,4 +1,5 @@
import base64 import base64
from inspect import isfunction, iscoroutinefunction
from traceback import print_exc from traceback import print_exc
import asyncio import asyncio
import collections import collections
@ -124,6 +125,9 @@ class MyVad(webrtcvad.Vad):
if duration > 500: if duration > 500:
ret = frames_write_wave(self.voiced_frames) ret = frames_write_wave(self.voiced_frames)
if self.onvoiceend: if self.onvoiceend:
if iscoroutinefunction(self.onvoiceend):
await self.onvoiceend(ret)
else:
self.onvoiceend(ret) self.onvoiceend(ret)
else: else:
print('-----short voice------') print('-----short voice------')