yujuanqin's picture
update report file name
e5b5f3e
raw
history blame contribute delete
949 Bytes
import pytest
from lib.utils import read_audio, save_csv
from test_data.audios import read_emilia
from environment import REPORTS_DIR
@pytest.fixture(scope="module")
def whisper(get_platform):
if get_platform == "apple":
from lib.models.mac.whisper import WhisperCPP
return WhisperCPP()
elif get_platform == "intel":
from lib.models.intel.whisper import WhisperOv
return WhisperOv()
def test_whisper(whisper):
#TODO: 测试CER
report = []
for audio_file, text, duration in read_emilia(count_limit=20):
print(audio_file)
audio = read_audio(audio_file)
asr_text, time_cost = whisper.transcribe(audio, "zh")
report.append([audio_file,duration, text, asr_text, time_cost])
save_csv(REPORTS_DIR/"test_whisper.csv", ["audio", "duration", "ref", "asr", "time"], report)
speed = [i[4] for i in report]
print("Whisper average speed: ", sum(speed) / len(speed))