| 131 | } // namespace |
| 132 | |
| 133 | int main(int argc, char* argv[]) { |
| 134 | string wav = ""; |
| 135 | string graph = ""; |
| 136 | string labels = ""; |
| 137 | string ground_truth = ""; |
| 138 | string input_data_name = "decoded_sample_data:0"; |
| 139 | string input_rate_name = "decoded_sample_data:1"; |
| 140 | string output_name = "labels_softmax"; |
| 141 | int32 clip_duration_ms = 1000; |
| 142 | int32 clip_stride_ms = 30; |
| 143 | int32 average_window_ms = 500; |
| 144 | int32 time_tolerance_ms = 750; |
| 145 | int32 suppression_ms = 1500; |
| 146 | float detection_threshold = 0.7f; |
| 147 | bool verbose = false; |
| 148 | std::vector<Flag> flag_list = { |
| 149 | Flag("wav", &wav, "audio file to be identified"), |
| 150 | Flag("graph", &graph, "model to be executed"), |
| 151 | Flag("labels", &labels, "path to file containing labels"), |
| 152 | Flag("ground_truth", &ground_truth, |
| 153 | "path to file containing correct times and labels of words in the " |
| 154 | "audio as <word>,<timestamp in ms> lines"), |
| 155 | Flag("input_data_name", &input_data_name, |
| 156 | "name of input data node in model"), |
| 157 | Flag("input_rate_name", &input_rate_name, |
| 158 | "name of input sample rate node in model"), |
| 159 | Flag("output_name", &output_name, "name of output node in model"), |
| 160 | Flag("clip_duration_ms", &clip_duration_ms, |
| 161 | "length of recognition window"), |
| 162 | Flag("average_window_ms", &average_window_ms, |
| 163 | "length of window to smooth results over"), |
| 164 | Flag("time_tolerance_ms", &time_tolerance_ms, |
| 165 | "maximum gap allowed between a recognition and ground truth"), |
| 166 | Flag("suppression_ms", &suppression_ms, |
| 167 | "how long to ignore others for after a recognition"), |
| 168 | Flag("clip_stride_ms", &clip_stride_ms, "how often to run recognition"), |
| 169 | Flag("detection_threshold", &detection_threshold, |
| 170 | "what score is required to trigger detection of a word"), |
| 171 | Flag("verbose", &verbose, "whether to log extra debugging information"), |
| 172 | }; |
| 173 | string usage = tensorflow::Flags::Usage(argv[0], flag_list); |
| 174 | const bool parse_result = tensorflow::Flags::Parse(&argc, argv, flag_list); |
| 175 | if (!parse_result) { |
| 176 | LOG(ERROR) << usage; |
| 177 | return -1; |
| 178 | } |
| 179 | |
| 180 | // We need to call this to set up global state for TensorFlow. |
| 181 | tensorflow::port::InitMain(argv[0], &argc, &argv); |
| 182 | if (argc > 1) { |
| 183 | LOG(ERROR) << "Unknown argument " << argv[1] << "\n" << usage; |
| 184 | return -1; |
| 185 | } |
| 186 | |
| 187 | // First we load and initialize the model. |
| 188 | std::unique_ptr<tensorflow::Session> session; |
| 189 | Status load_graph_status = LoadGraph(graph, &session); |
| 190 | if (!load_graph_status.ok()) { |
nothing calls this directly
no test coverage detected