mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-24 04:19:48 +01:00
fix: 修复 performance_tester 异步配置加载错误
This commit is contained in:
parent
ea6b0c3746
commit
2a465f0fb5
5 changed files with 30 additions and 25 deletions
|
|
@ -18,8 +18,8 @@ description = "大语言模型性能测试"
|
|||
|
||||
|
||||
class LLMPerformanceTester:
|
||||
def __init__(self):
|
||||
self.config = load_config()
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
# 使用更符合智能体场景的测试内容,包含系统提示词
|
||||
self.system_prompt = self._load_system_prompt()
|
||||
self.test_sentences = self.config.get("module_test", {}).get(
|
||||
|
|
@ -536,7 +536,8 @@ class LLMPerformanceTester:
|
|||
|
||||
|
||||
async def main():
|
||||
tester = LLMPerformanceTester()
|
||||
config = await load_config()
|
||||
tester = LLMPerformanceTester(config)
|
||||
await tester.run()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ except ImportError:
|
|||
dashscope = None
|
||||
|
||||
class BaseASRTester:
|
||||
def __init__(self, config_key: str):
|
||||
self.config = load_config()
|
||||
def __init__(self, config_key: str, config):
|
||||
self.config = config
|
||||
self.config_key = config_key
|
||||
self.asr_config = self.config.get("ASR", {}).get(config_key, {})
|
||||
self.test_audio_files = self._load_test_audio_files()
|
||||
|
|
@ -63,8 +63,8 @@ class BaseASRTester:
|
|||
|
||||
|
||||
class DoubaoStreamASRTester(BaseASRTester):
|
||||
def __init__(self):
|
||||
super().__init__("DoubaoStreamASR")
|
||||
def __init__(self, config):
|
||||
super().__init__("DoubaoStreamASR", config)
|
||||
from core.providers.asr.doubao_stream import ASRProvider as DoubaoStreamProvider
|
||||
self.provider = DoubaoStreamProvider(self.asr_config, delete_audio_file=False)
|
||||
|
||||
|
|
@ -128,8 +128,8 @@ class DoubaoStreamASRTester(BaseASRTester):
|
|||
|
||||
|
||||
class QwenASRFlashTester(BaseASRTester):
|
||||
def __init__(self):
|
||||
super().__init__("Qwen3ASRFlash")
|
||||
def __init__(self, config):
|
||||
super().__init__("Qwen3ASRFlash", config)
|
||||
|
||||
async def _test_single(self, audio_file_info):
|
||||
temp_file_path = None
|
||||
|
|
@ -213,8 +213,8 @@ class QwenASRFlashTester(BaseASRTester):
|
|||
|
||||
|
||||
class XunfeiStreamASRTester(BaseASRTester):
|
||||
def __init__(self):
|
||||
super().__init__("XunfeiStreamASR")
|
||||
def __init__(self, config):
|
||||
super().__init__("XunfeiStreamASR", config)
|
||||
|
||||
def _create_url(self):
|
||||
url = "wss://iat-api.xfyun.cn/v2/iat"
|
||||
|
|
@ -325,13 +325,14 @@ class XunfeiStreamASRTester(BaseASRTester):
|
|||
|
||||
return self._calculate_result("讯飞流式ASR", latencies, test_count)
|
||||
class ASRPerformanceSuite:
|
||||
def __init__(self):
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self.testers = []
|
||||
self.results = []
|
||||
|
||||
def register_tester(self, tester_class):
|
||||
try:
|
||||
tester = tester_class()
|
||||
tester = tester_class(self.config)
|
||||
self.testers.append(tester)
|
||||
print(f"已注册测试器: {tester.config_key}")
|
||||
except Exception as e:
|
||||
|
|
@ -390,7 +391,8 @@ async def main():
|
|||
parser.add_argument("--count", type=int, default=5, help="测试次数")
|
||||
args = parser.parse_args()
|
||||
|
||||
suite = ASRPerformanceSuite()
|
||||
config = await load_config()
|
||||
suite = ASRPerformanceSuite(config)
|
||||
suite.register_tester(DoubaoStreamASRTester)
|
||||
suite.register_tester(QwenASRFlashTester)
|
||||
suite.register_tester(XunfeiStreamASRTester)
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ from config.settings import load_config
|
|||
|
||||
description = "流式TTS语音合成首词耗时测试"
|
||||
class StreamTTSPerformanceTester:
|
||||
def __init__(self):
|
||||
self.config = load_config()
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self.test_texts = [
|
||||
"你好,这是一句话。"
|
||||
]
|
||||
|
|
@ -663,7 +663,8 @@ async def main():
|
|||
parser.add_argument("--count", type=int, default=5, help="每个TTS服务的测试次数")
|
||||
|
||||
args = parser.parse_args()
|
||||
await StreamTTSPerformanceTester().run(args.text, args.count)
|
||||
config = await load_config()
|
||||
await StreamTTSPerformanceTester(config).run(args.text, args.count)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ description = "非流式语音合成性能测试"
|
|||
|
||||
|
||||
class TTSPerformanceTester:
|
||||
def __init__(self):
|
||||
self.config = load_config()
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self.test_sentences = self.config.get("module_test", {}).get(
|
||||
"test_sentences",
|
||||
[
|
||||
|
|
@ -190,10 +190,10 @@ class TTSPerformanceTester:
|
|||
|
||||
# 为了performance_tester.py的调用需求
|
||||
async def main():
|
||||
tester = TTSPerformanceTester()
|
||||
config = await load_config()
|
||||
tester = TTSPerformanceTester(config)
|
||||
await tester.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
tester = TTSPerformanceTester()
|
||||
asyncio.run(tester.run())
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ description = "视觉识别模型性能测试"
|
|||
|
||||
|
||||
class AsyncVisionPerformanceTester:
|
||||
def __init__(self):
|
||||
self.config = load_config()
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
||||
self.test_images = [
|
||||
"../../docs/images/demo1.png",
|
||||
|
|
@ -184,7 +184,8 @@ class AsyncVisionPerformanceTester:
|
|||
|
||||
|
||||
async def main():
|
||||
tester = AsyncVisionPerformanceTester()
|
||||
config = await load_config()
|
||||
tester = AsyncVisionPerformanceTester(config)
|
||||
await tester.run()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue