mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-08-10 02:22:16 +00:00
add benchmark code.
It's about 3x faster than kaldi for a wave with duration 320 seconds on CPU.
This commit is contained in:
parent
7c8ef68bb5
commit
917df77946
@ -4,6 +4,8 @@
|
||||
|
||||
#include "kaldifeat/python/csrc/kaldifeat.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "kaldifeat/csrc/feature-fbank.h"
|
||||
#include "torch/torch.h"
|
||||
|
||||
@ -19,7 +21,19 @@ PYBIND11_MODULE(_kaldifeat, m) {
|
||||
Fbank fbank(fbank_opts);
|
||||
float vtln_warp = 1.0f;
|
||||
|
||||
std::chrono::steady_clock::time_point begin =
|
||||
std::chrono::steady_clock::now();
|
||||
|
||||
torch::Tensor ans = fbank.ComputeFeatures(tensor, vtln_warp);
|
||||
std::chrono::steady_clock::time_point end =
|
||||
std::chrono::steady_clock::now();
|
||||
std::cout << "Time difference = "
|
||||
<< std::chrono::duration_cast<std::chrono::microseconds>(end -
|
||||
begin)
|
||||
.count() /
|
||||
1000000.
|
||||
<< "[s]" << std::endl;
|
||||
|
||||
return ans;
|
||||
});
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ def main():
|
||||
a *= 32768
|
||||
tensor = torch.from_numpy(a)
|
||||
ans = _kaldifeat.test(tensor)
|
||||
torch.set_printoptions(profile="full")
|
||||
print(ans.shape)
|
||||
print(ans)
|
||||
# torch.set_printoptions(profile="full")
|
||||
# print(ans.shape)
|
||||
# print(ans)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user