|
|
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 asr(get_platform): |
|
|
if get_platform == "apple": |
|
|
from lib.models.mac.funasr import FunAsrOnnx |
|
|
return FunAsrOnnx() |
|
|
elif get_platform == "intel": |
|
|
from lib.models.intel.funasr import FunAsrOv |
|
|
return FunAsrOv() |
|
|
|
|
|
|
|
|
def test_funasr(asr): |
|
|
|
|
|
report = [] |
|
|
for audio_file, text, duration in read_emilia(count_limit=20): |
|
|
print(audio_file) |
|
|
audio = read_audio(audio_file) |
|
|
asr_text, time_cost = asr.transcribe(audio) |
|
|
report.append([audio_file,duration, text, asr_text, time_cost]) |
|
|
save_csv(REPORTS_DIR/"test_funasr.csv", ["audio", "duration", "ref", "asr", "time"], report) |
|
|
speed=[i[4] for i in report] |
|
|
print("Funasr average speed: ", sum(speed)/len(speed)) |