mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-08-12 11:32:17 +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 "kaldifeat/python/csrc/kaldifeat.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include "kaldifeat/csrc/feature-fbank.h"
|
#include "kaldifeat/csrc/feature-fbank.h"
|
||||||
#include "torch/torch.h"
|
#include "torch/torch.h"
|
||||||
|
|
||||||
@ -19,7 +21,19 @@ PYBIND11_MODULE(_kaldifeat, m) {
|
|||||||
Fbank fbank(fbank_opts);
|
Fbank fbank(fbank_opts);
|
||||||
float vtln_warp = 1.0f;
|
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);
|
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;
|
return ans;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ def main():
|
|||||||
a *= 32768
|
a *= 32768
|
||||||
tensor = torch.from_numpy(a)
|
tensor = torch.from_numpy(a)
|
||||||
ans = _kaldifeat.test(tensor)
|
ans = _kaldifeat.test(tensor)
|
||||||
torch.set_printoptions(profile="full")
|
# torch.set_printoptions(profile="full")
|
||||||
print(ans.shape)
|
# print(ans.shape)
|
||||||
print(ans)
|
# print(ans)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user