update:解决base类修改后测速工具兼容性问题

This commit is contained in:
FAN-yeB
2026-04-27 15:06:40 +08:00
parent 3510282cd5
commit a432c295d3
2 changed files with 17 additions and 1 deletions
@@ -68,7 +68,7 @@ class ASRPerformanceTester:
"""测试单个音频文件的性能"""
try:
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:
return None
@@ -2,6 +2,7 @@ import asyncio
import logging
import os
import time
import threading
from typing import Dict
import yaml
from tabulate import tabulate
@@ -44,6 +45,21 @@ class TTSPerformanceTester:
module_type = config.get("type", tts_name)
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}")
# 连接测试