Files
product/scripts/tts_stress.py
T
2026-03-27 10:49:34 +08:00

32 lines
870 B
Python

from __future__ import annotations
import asyncio
import os
import sys
import time
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
from services.tts import TTSService
async def main() -> None:
svc = TTSService()
texts = [f"第{i+1}句,语音稳定性压力测试。" for i in range(20)]
costs = []
for i, text in enumerate(texts):
t0 = time.perf_counter()
audio, sr = await svc.synthesize(text)
dt = int((time.perf_counter() - t0) * 1000)
costs.append(dt)
print(f"round={i+1} ms={dt} samples={audio.shape[0]} sr={sr}")
p50 = sorted(costs)[len(costs) // 2]
print("tts.health:", svc.health)
print("tts stress p50_ms:", p50, "max_ms:", max(costs))
if __name__ == "__main__":
asyncio.run(main())