File size: 921 Bytes
1e495f3
 
 
 
 
 
b295d06
1e495f3
b295d06
 
1e495f3
b295d06
 
1e495f3
b295d06
e5b5f3e
1e495f3
 
42742c6
1e495f3
 
 
 
e5b5f3e
42742c6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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):
    #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 = 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))