update:内存泄漏

This commit is contained in:
3030332422
2025-11-23 11:55:38 +08:00
parent 39cd0fe1ac
commit 5d439a4168
8 changed files with 107 additions and 50 deletions
@@ -10,6 +10,7 @@ import traceback
import threading
import opuslib_next
import concurrent.futures
import gc
from abc import ABC, abstractmethod
from config.logger import setup_logging
from typing import Optional, Tuple, List
@@ -241,6 +242,7 @@ class ASRProviderBase(ABC):
@staticmethod
def decode_opus(opus_data: List[bytes]) -> List[bytes]:
"""将Opus音频数据解码为PCM数据"""
decoder = None
try:
decoder = opuslib_next.Decoder(16000, 1)
pcm_data = []
@@ -265,3 +267,7 @@ class ASRProviderBase(ABC):
except Exception as e:
logger.bind(tag=TAG).error(f"音频解码过程发生错误: {e}")
return []
finally:
if decoder:
del decoder
gc.collect()