Commit 453689cc1c2dcafa61b1a32feefc6f29e1f3bcfb
1 parent
ccc268c5
Exists in
master
and in
2 other branches
Correção da sincronização do Recognizer.
Showing
2 changed files
with
20 additions
and
19 deletions
Show diff stats
recognize/src/include/recognize.h
@@ -75,7 +75,7 @@ private: | @@ -75,7 +75,7 @@ private: | ||
75 | void executeJuliusEngine(); | 75 | void executeJuliusEngine(); |
76 | void filterOutputJulius(); | 76 | void filterOutputJulius(); |
77 | void generateConfidence(); | 77 | void generateConfidence(); |
78 | - void notifyListeners(char* text); | 78 | + void notifyListeners(char* text, int64_t pts); |
79 | void notifyEndExtraction(int sentences_size); | 79 | void notifyEndExtraction(int sentences_size); |
80 | 80 | ||
81 | void cleanFiles(); | 81 | void cleanFiles(); |
recognize/src/recognize.cpp
@@ -32,6 +32,7 @@ | @@ -32,6 +32,7 @@ | ||
32 | #define FIND_SENTENCE "\"sentence1:\"" | 32 | #define FIND_SENTENCE "\"sentence1:\"" |
33 | 33 | ||
34 | #define FILENAME_AUDIOPART "audio00" | 34 | #define FILENAME_AUDIOPART "audio00" |
35 | +#define AUDIO_SILENT "<input rejected by short input>" | ||
35 | 36 | ||
36 | #define PROGRAM "ffmpeg" // ffmpeg | 37 | #define PROGRAM "ffmpeg" // ffmpeg |
37 | #define PTS_PATTERN 1000 | 38 | #define PTS_PATTERN 1000 |
@@ -121,7 +122,7 @@ void Recognize::Run(){ | @@ -121,7 +122,7 @@ void Recognize::Run(){ | ||
121 | cleanFiles(); | 122 | cleanFiles(); |
122 | 123 | ||
123 | finished = true; | 124 | finished = true; |
124 | - notifyEndExtraction(count_lines-1); | 125 | + notifyEndExtraction(count_lines); |
125 | } | 126 | } |
126 | 127 | ||
127 | void Recognize::setFrequency(int freq) { | 128 | void Recognize::setFrequency(int freq) { |
@@ -343,8 +344,8 @@ void Recognize::filterOutputJulius() { | @@ -343,8 +344,8 @@ void Recognize::filterOutputJulius() { | ||
343 | sentences = new std::list<char*>(); | 344 | sentences = new std::list<char*>(); |
344 | 345 | ||
345 | string command = "cat "; | 346 | string command = "cat "; |
346 | - command.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep "). | ||
347 | - append(FIND_SENTENCE).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT); | 347 | + command.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e "). |
348 | + append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT); | ||
348 | 349 | ||
349 | system(command.c_str()); | 350 | system(command.c_str()); |
350 | //printf("\n\n---> command: %s\n\n", command.c_str()); | 351 | //printf("\n\n---> command: %s\n\n", command.c_str()); |
@@ -365,17 +366,20 @@ void Recognize::filterOutputJulius() { | @@ -365,17 +366,20 @@ void Recognize::filterOutputJulius() { | ||
365 | do { | 366 | do { |
366 | getline(in, line); | 367 | getline(in, line); |
367 | if (line.length() > 0) { | 368 | if (line.length() > 0) { |
368 | - sizeLine = (int)line.length(); | ||
369 | - strFilter = line.substr(strlen(FIND_SENTENCE), sizeLine); | ||
370 | - sentence_ptr = new char[strFilter.length()+1]; | ||
371 | - strcpy(sentence_ptr, (char*) strFilter.c_str()); | ||
372 | - if(getConfidence()) | ||
373 | - notifyListeners(sentence_ptr); | ||
374 | - else | ||
375 | - notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE"); | ||
376 | - scores.erase(scores.begin()); | 369 | + if (line != AUDIO_SILENT){ |
370 | + sizeLine = (int)line.length(); | ||
371 | + strFilter = line.substr(strlen(FIND_SENTENCE), sizeLine); | ||
372 | + sentence_ptr = new char[strFilter.length()+1]; | ||
373 | + strcpy(sentence_ptr, (char*) strFilter.c_str()); | ||
374 | + if(getConfidence()) | ||
375 | + notifyListeners(sentence_ptr, pts.front()); | ||
376 | + else | ||
377 | + notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", pts.front()); | ||
378 | + scores.erase(scores.begin()); | ||
379 | + count_lines++; | ||
380 | + } | ||
381 | + pts.erase(pts.begin()); | ||
377 | } | 382 | } |
378 | - count_lines++; | ||
379 | } while (!in.eof()); | 383 | } while (!in.eof()); |
380 | in.close(); | 384 | in.close(); |
381 | } | 385 | } |
@@ -386,15 +390,12 @@ void Recognize::filterOutputJulius() { | @@ -386,15 +390,12 @@ void Recognize::filterOutputJulius() { | ||
386 | } | 390 | } |
387 | 391 | ||
388 | 392 | ||
389 | -void Recognize::notifyListeners(char* text) { | 393 | +void Recognize::notifyListeners(char* text, int64_t pts) { |
390 | //cout << "NOTIFY: " << text << endl; | 394 | //cout << "NOTIFY: " << text << endl; |
391 | 395 | ||
392 | - int64_t pts_run = pts.front(); | ||
393 | for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ | 396 | for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ |
394 | - (*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts_run)); | ||
395 | - | 397 | + (*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts)); |
396 | } | 398 | } |
397 | - pts.erase(pts.begin()); | ||
398 | 399 | ||
399 | } | 400 | } |
400 | 401 |