PCM音频模式

This commit is contained in:
玄凤科技
2025-05-06 14:57:29 +08:00
parent 9fc1285c09
commit bde260b330
12 changed files with 66 additions and 127 deletions
@@ -226,21 +226,6 @@ class ASRProvider(ASRProviderBase):
logger.bind(tag=TAG).error(f"ASR request failed: {e}", exc_info=True)
return None
@staticmethod
def decode_opus(opus_data: List[bytes], session_id: str) -> List[bytes]:
decoder = opuslib_next.Decoder(16000, 1) # 16kHz, 单声道
pcm_data = []
for opus_packet in opus_data:
try:
pcm_frame = decoder.decode(opus_packet, 960) # 960 samples = 60ms
pcm_data.append(pcm_frame)
except opuslib_next.OpusError as e:
logger.bind(tag=TAG).error(f"Opus解码错误: {e}", exc_info=True)
return pcm_data
@staticmethod
def slice_data(data: bytes, chunk_size: int) -> (list, bool):
"""