Commit 3c0537340be7b88576fa4ebad4c163fd3940c5e2
1 parent
8123bb94
Exists in
master
and in
2 other branches
Correção na transcodificação WEBM do Service Text.
Showing
5 changed files
with
39 additions
and
26 deletions
Show diff stats
recognize/src/recognize.cpp
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #define INPUT_PATTERN 1 /* 1 = Raw file, 2 = Mic */ |
| 19 | 19 | #define BLOCS_PATTERN 10 |
| 20 | 20 | #define SIZE_BUFFER 256 |
| 21 | -#define CONFIDENCE_RATE 0.40 | |
| 21 | +#define CONFIDENCE_RATE 0.50 | |
| 22 | 22 | |
| 23 | 23 | #define PATH_GTAAAS_WEB "gtaaas_user/gtaaas_web/public/uploads/videos/" |
| 24 | 24 | #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav" |
| ... | ... | @@ -284,15 +284,27 @@ void Recognize::generateConfidence() { |
| 284 | 284 | if (line.length() > 0) { |
| 285 | 285 | istream_iterator<std::string> beg(buf), end; |
| 286 | 286 | vector<string> tokens(beg, end); |
| 287 | - float sizeScores = 0; | |
| 287 | + float sizeAvgScores = 0; | |
| 288 | + float sizeLowScores = 0; | |
| 288 | 289 | float avgScores = 0; |
| 290 | + float lowScores = 0; | |
| 289 | 291 | int i; |
| 290 | 292 | for(i=2; i < tokens.size()-1; i++){ |
| 291 | 293 | istringstream(tokens[i]) >> tmp; |
| 292 | - avgScores += tmp; | |
| 293 | - sizeScores++; | |
| 294 | + if (tmp > confidenceRate){ | |
| 295 | + avgScores += tmp; | |
| 296 | + sizeAvgScores++; | |
| 297 | + } | |
| 298 | + else{ | |
| 299 | + lowScores += tmp; | |
| 300 | + sizeLowScores++; | |
| 301 | + } | |
| 294 | 302 | } |
| 295 | - scores.push_back(avgScores/sizeScores); | |
| 303 | + if (lowScores > 0){ | |
| 304 | + lowScores /= sizeLowScores; | |
| 305 | + sizeAvgScores++; | |
| 306 | + } | |
| 307 | + scores.push_back((avgScores+lowScores)/sizeAvgScores); | |
| 296 | 308 | } |
| 297 | 309 | } while (!in.eof()); |
| 298 | 310 | in.close(); |
| ... | ... | @@ -300,6 +312,7 @@ void Recognize::generateConfidence() { |
| 300 | 312 | } |
| 301 | 313 | |
| 302 | 314 | bool Recognize::getConfidence(int i){ |
| 315 | + //cout << "CONFIDENCE: " << scores[i] << endl; | |
| 303 | 316 | if (scores[i] < confidenceRate) |
| 304 | 317 | return false; |
| 305 | 318 | return true; |
| ... | ... | @@ -355,6 +368,7 @@ void Recognize::filterOutputJulius() { |
| 355 | 368 | |
| 356 | 369 | |
| 357 | 370 | void Recognize::notifyListeners(char* text) { |
| 371 | + //cout << "NOTIFY: " << text << endl; | |
| 358 | 372 | |
| 359 | 373 | int64_t pts = PTS_PATTERN; |
| 360 | 374 | for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ | ... | ... |
servico/src/include/serviceWindowGeneration.h
servico/src/include/serviceWindowGenerationFromText.h
servico/src/serviceWindowGeneration.cpp
| ... | ... | @@ -73,6 +73,11 @@ void ServiceWindowGeneration::setPathLibras(char* _path_libras) { |
| 73 | 73 | DDPRINTF("Path TS File: %s\n", _path_libras); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | +char* ServiceWindowGeneration::getPathLibras() { | |
| 77 | + return path_libras; | |
| 78 | +} | |
| 79 | + | |
| 80 | + | |
| 76 | 81 | void ServiceWindowGeneration::setServiceType(int type) { |
| 77 | 82 | serviceType = type; |
| 78 | 83 | } | ... | ... |
servico/src/serviceWindowGenerationFromText.cpp
| ... | ... | @@ -3,13 +3,14 @@ |
| 3 | 3 | |
| 4 | 4 | |
| 5 | 5 | #define PATH_LIBRAS "libras/video/" |
| 6 | -#define OUTPUT_VIDEO_WEB "gtaaas_user/gtaaas-plugin-server/videos/libras.webm" | |
| 6 | +#define OUTPUT_VIDEO_WEB "gtaaas_user/gtaaas-plugin-server/videos/" | |
| 7 | 7 | #define MAX_SIZE_PATH 256 |
| 8 | 8 | |
| 9 | 9 | ServiceWindowGenerationFromText::ServiceWindowGenerationFromText (char* _path_file, char* _username, int _transp, int _serviceType, char* _client_type) { |
| 10 | 10 | |
| 11 | 11 | path_file = _path_file; |
| 12 | 12 | client_type = _client_type; |
| 13 | + id = _username; | |
| 13 | 14 | setTransparency(_transp); |
| 14 | 15 | setServiceType(_serviceType); |
| 15 | 16 | char* final_path = new char[MAX_SIZE_PATH]; |
| ... | ... | @@ -72,23 +73,14 @@ void ServiceWindowGenerationFromText::Run() { |
| 72 | 73 | |
| 73 | 74 | void ServiceWindowGenerationFromText::transcodeVideoToWebm() { |
| 74 | 75 | |
| 75 | - FILE *video_webm; | |
| 76 | - video_webm = fopen(OUTPUT_VIDEO_WEB, "r"); | |
| 77 | - if (video_webm != NULL) { | |
| 78 | - string cmd = "rm "; | |
| 79 | - cmd.append(OUTPUT_VIDEO_WEB); | |
| 80 | - printf("[INFO]: Remove video libras.webm: %s\n", cmd.c_str()); | |
| 81 | - system(cmd.c_str()); | |
| 82 | - fclose(video_webm); | |
| 83 | - } | |
| 84 | - | |
| 85 | - char* command = (char*) malloc (INT_MAX); | |
| 86 | - strcpy(command, "ffmpeg -i "); | |
| 87 | - strcat(command, PATH_LIBRAS); | |
| 88 | - strcat(command, " -vcodec libvpx -acodec libvorbis "); | |
| 89 | - strcat(command, OUTPUT_VIDEO_WEB); | |
| 90 | - printf("[INFO]: Transcodification command -> %s\n", command); | |
| 91 | - system(command); | |
| 92 | - free(video_webm); | |
| 93 | - free(command); | |
| 94 | -} | |
| 76 | + string command = "ffmpeg -i "; | |
| 77 | + command.append(getPathLibras()) | |
| 78 | + .append(" -vcodec libvpx -acodec libvorbis ") | |
| 79 | + .append(OUTPUT_VIDEO_WEB) | |
| 80 | + .append(id) | |
| 81 | + .append(".webm") | |
| 82 | + .append(" && rm ") | |
| 83 | + .append(getPathLibras()); | |
| 84 | + printf("[INFO]: Transcodification command -> %s\n", command.c_str()); | |
| 85 | + system(command.c_str()); | |
| 86 | +} | |
| 95 | 87 | \ No newline at end of file | ... | ... |