78 using namespace kaldi;
82 "Computes Equal Error Rate\n" 83 "Input is a series of lines, each with two fields.\n" 84 "The first field must be a numeric score, and the second\n" 85 "either the string 'target' or 'nontarget'. \n" 86 "The EER will be printed to the standard output.\n" 88 "Usage: compute-eer <scores-in>\n" 89 "e.g.: compute-eer -\n";
94 if (po.NumArgs() != 1) {
99 std::string scores_rxfilename = po.GetArg(1);
101 std::vector<BaseFloat> target_scores, nontarget_scores;
102 Input ki(scores_rxfilename);
105 while (std::getline(ki.Stream(), line)) {
106 std::vector<std::string> split_line;
109 if (split_line.size() != 2) {
110 KALDI_ERR <<
"Invalid input line (must have two fields): " 114 KALDI_ERR <<
"Invalid input line (first field must be float): " 117 if (split_line[1] ==
"target")
118 target_scores.push_back(score);
119 else if (split_line[1] ==
"nontarget")
120 nontarget_scores.push_back(score);
122 KALDI_ERR <<
"Invalid input line (second field must be " 123 <<
"'target' or 'nontarget')";
126 if (target_scores.empty() && nontarget_scores.empty())
128 if (target_scores.empty())
130 if (nontarget_scores.empty())
131 KALDI_ERR <<
"No non-target scores seen.";
136 KALDI_LOG <<
"Equal error rate is " << (100.0 * eer)
137 <<
"%, at threshold " << threshold;
139 std::cout.precision(4);
140 std::cout << (100.0 * eer);
143 }
catch(
const std::exception &e) {
144 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void SplitStringToVector(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< std::string > *out)
Split a string using any of the single character delimiters.
bool ConvertStringToReal(const std::string &str, T *out)
ConvertStringToReal converts a string into either float or double and returns false if there was any ...
BaseFloat ComputeEer(std::vector< BaseFloat > *target_scores, std::vector< BaseFloat > *nontarget_scores, BaseFloat *threshold)
ComputeEer computes the Equal Error Rate (EER) for the given scores and returns it as a proportion be...