test/test_speed.py

35 lines
1.1 KiB
Python

import time
import requests
import sys
url = "http://localhost:8000/v1/audio/transcriptions"
file_path = "/dep/qwen3-asr/TicNote客户服务_20260518_100301-录音.m4a"
print(f"Starting transcription test for {file_path} using qwen3-asr-0.6b...")
start_time = time.time()
try:
with open(file_path, "rb") as f:
files = {"file": f}
data = {
"response_format": "verbose_json",
"enable_speaker_diarization": "false", # Disable to speed up and focus on ASR
}
response = requests.post(url, files=files, data=data)
end_time = time.time()
cost_time = end_time - start_time
if response.status_code == 200:
res_json = response.json()
text_len = len(res_json.get("text", ""))
print(f"Success! Transcription length: {text_len} chars.")
print(f"Total time elapsed: {cost_time:.2f} seconds")
print(f"Audio processed: {file_path}")
else:
print(f"Failed! Status code: {response.status_code}")
print(response.text)
except Exception as e:
print(f"Error occurred: {e}")