mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 17:13:54 +08:00
Merge pull request #3136 from xinnan-tech/performance_tester
update:解决base类修改后测速工具兼容性问题
This commit is contained in:
@@ -68,7 +68,7 @@ class ASRPerformanceTester:
|
|||||||
"""测试单个音频文件的性能"""
|
"""测试单个音频文件的性能"""
|
||||||
try:
|
try:
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
text, _ = await stt.speech_to_text([audio_data], "1", stt.audio_format)
|
text, _ = await stt.speech_to_text_wrapper([audio_data], "1", stt.audio_format)
|
||||||
if text is None:
|
if text is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
import yaml
|
import yaml
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
@@ -44,6 +45,21 @@ class TTSPerformanceTester:
|
|||||||
module_type = config.get("type", tts_name)
|
module_type = config.get("type", tts_name)
|
||||||
tts = create_tts_instance(module_type, config, delete_audio_file=True)
|
tts = create_tts_instance(module_type, config, delete_audio_file=True)
|
||||||
|
|
||||||
|
# 设置 mock conn 对象,避免 TTS 实现访问 self.conn.sample_rate 时为 None
|
||||||
|
class MockConn:
|
||||||
|
sample_rate = 16000
|
||||||
|
audio_format = "pcm"
|
||||||
|
stop_event = threading.Event() # 需要是真正的 Event 对象
|
||||||
|
client_abort = False
|
||||||
|
headers = {}
|
||||||
|
tts.conn = MockConn()
|
||||||
|
|
||||||
|
# 设置 mock opus_encoder,避免某些 TTS 访问 self.opus_encoder 时为 None
|
||||||
|
class MockOpusEncoder:
|
||||||
|
pass
|
||||||
|
if not hasattr(tts, 'opus_encoder') or tts.opus_encoder is None:
|
||||||
|
tts.opus_encoder = MockOpusEncoder()
|
||||||
|
|
||||||
print(f"测试 TTS: {tts_name}")
|
print(f"测试 TTS: {tts_name}")
|
||||||
|
|
||||||
# 连接测试
|
# 连接测试
|
||||||
|
|||||||
Reference in New Issue
Block a user