refactor: replace Kokoro-82M with suno/bark for TTS, update HF cache path, and add model warmup on startup.
This commit is contained in:
@@ -16,8 +16,9 @@ from unittest.mock import Mock, MagicMock, patch
|
||||
import tempfile
|
||||
import numpy as np
|
||||
|
||||
# 确保可以导入tts_asr模块
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||||
# 确保可以导入backend和tts_asr模块
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
|
||||
|
||||
class TestAppleSiliconDetection(unittest.TestCase):
|
||||
@@ -174,7 +175,7 @@ class TestModelSizeSelection(unittest.TestCase):
|
||||
import backend.tts_asr as tts_asr_module
|
||||
importlib.reload(tts_asr_module)
|
||||
|
||||
from backend.tts_asr import _get_recommended_model_size
|
||||
from backend.tts_asr import _get_recommended_model_size, WHISPER_MODEL_SIZES
|
||||
# 应该回退到推荐大小而不崩溃
|
||||
size = _get_recommended_model_size()
|
||||
self.assertIn(size, WHISPER_MODEL_SIZES.keys())
|
||||
@@ -299,8 +300,8 @@ class TestModelCacheCheck(unittest.TestCase):
|
||||
"""测试离线模式下缺失模型的处理"""
|
||||
from backend.tts_asr import _check_model_cached
|
||||
|
||||
# 模拟transformers缓存路径
|
||||
with patch('transformers.file_utils.default_cache_path', '/nonexistent/path'):
|
||||
# 模拟缓存路径
|
||||
with patch('huggingface_hub.constants.HF_HUB_CACHE', '/nonexistent/path'):
|
||||
result = _check_model_cached('nonexistent/model')
|
||||
# 应该返回False(模型未缓存)
|
||||
self.assertFalse(result)
|
||||
|
||||
Reference in New Issue
Block a user