| 542 | } |
| 543 | |
| 544 | double asr_error(const std::string & reference, const std::string & hypothesis, const std::string & language) { |
| 545 | if (language == "en") { |
| 546 | const auto ref = normalize_for_wer(reference); |
| 547 | const auto hyp = normalize_for_wer(hypothesis); |
| 548 | if (ref.empty()) { |
| 549 | return hyp.empty() ? 0.0 : 1.0; |
| 550 | } |
| 551 | return static_cast<double>(edit_distance(ref, hyp)) / static_cast<double>(ref.size()); |
| 552 | } |
| 553 | const auto ref = normalize_for_cer(reference); |
| 554 | const auto hyp = normalize_for_cer(hypothesis); |
| 555 | if (ref.empty()) { |
| 556 | return hyp.empty() ? 0.0 : 1.0; |
| 557 | } |
| 558 | return static_cast<double>(edit_distance(ref, hyp)) / static_cast<double>(ref.size()); |
| 559 | } |
| 560 | |
| 561 | } // namespace |
| 562 |
no test coverage detected