业务场景
需求:计算 RTF(实时率)。
说明:
对于语音处理,
R T F = 音 频 处 理 时 间 音 频 时 长 RTF = \frac{音频处理时间}{音频时长} RTF=音频时长音频处理时间
获取总的音频时长,
awk '{sum+=$NF}END{print sum}' path/to/utt2dur
# i.e Ouput is 3000.00, unit is second
获取总的处理时间,因为是用 time ./run.sh
跑的,输出的时间格式为 H:M:S
,譬如
$ time bash -x ./lg_run_gmm.sh --dnn false --nj 4 test/polly_punct_gmm test/result/polly_punct_gmm 2>&1 | tee ./logs/lg_run_gmm.sh.polly_punct.log
Done. elapse=713
bash -x ./lg_run_gmm.sh --dnn false --nj 4 test/polly_punct_gmm 2>&1 2370.61s user 11.69s system 334% cpu 11:52.82 total
tee ./logs/lg_run_gmm.sh.polly_punct.log 0.00s user 0.01s system 0% cpu 11:52.81 total
11:52.81
这个时间是我需要转化的。
使用 Python 计算时间差
转化成 time 数据类型:
<