Commit 7e25af70699e69798d29c0e54c2e88dec0476b85

Authored by Wesnydy Ribeiro
1 parent 40535e79
Exists in master and in 1 other branch devel

Adicionado a verificação da existência de variáveis de ambiente

recognize/src/include/recognize.h
@@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
23 #define SIZE_BUFFER 256 23 #define SIZE_BUFFER 256
24 #define CONFIDENCE_RATE 0.10 24 #define CONFIDENCE_RATE 0.10
25 25
  26 +#define PATH_JCONFIG "vlibras_user/vlibras-core/recognize/src/julius.jconf"
26 #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav" 27 #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav"
27 #define PATH_AUDIO_PARTS "/audio/parts/" 28 #define PATH_AUDIO_PARTS "/audio/parts/"
28 #define FILENAME_RECOGNIZED_OUT "/audio/recognized.out" 29 #define FILENAME_RECOGNIZED_OUT "/audio/recognized.out"
recognize/src/recognize.cpp
@@ -208,10 +208,19 @@ void Recognize::breakVideoParts(int timeTotal) { @@ -208,10 +208,19 @@ void Recognize::breakVideoParts(int timeTotal) {
208 208
209 void Recognize::executeJuliusEngine() { 209 void Recognize::executeJuliusEngine() {
210 210
211 - string command, type, freqStr; 211 + string type, freqStr;
  212 + string command = "julius - C ";
212 char cfreq[10]; 213 char cfreq[10];
213 214
214 - command = "julius -C vlibras_user/vlibras-core/recognize/src/julius.jconf -input "; 215 + char* jPath;
  216 + jPath = getenv("JCONFIG");
  217 +
  218 + if(jPath != NULL)
  219 + command.append(jPath);
  220 + else
  221 + command.append(PATH_JCONFIG);
  222 +
  223 + command.append(" -input ");
215 224
216 if (inputType == 1) 225 if (inputType == 1)
217 type = "rawfile"; 226 type = "rawfile";
servico/src/serviceWindowGenerationFromRec.cpp
@@ -34,9 +34,13 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec( @@ -34,9 +34,13 @@ ServiceWindowGenerationFromRec::ServiceWindowGenerationFromRec(
34 numero_legendas = INT_MAX; 34 numero_legendas = INT_MAX;
35 legendas_enviadas = 0; 35 legendas_enviadas = 0;
36 vetor_pts = new vector<int64_t >(); 36 vetor_pts = new vector<int64_t >();
37 - rec = new Recognize(path_input, id);// parametro 1 indica que é um cliente web 37 + rec = new Recognize(path_input, id);
38 tradutor = new TradutorPortGlosa(); 38 tradutor = new TradutorPortGlosa();
39 - setPathContents(); 39 + try{
  40 + setPathContents();
  41 + }catch(RuntimeException ex){
  42 + throw ServiceException(ex.getMessage());
  43 + }
40 running = true; 44 running = true;
41 finish = false; 45 finish = false;
42 DPRINTF("Done!\n"); 46 DPRINTF("Done!\n");
@@ -83,13 +87,20 @@ void ServiceWindowGenerationFromRec::setPathLibras(){ @@ -83,13 +87,20 @@ void ServiceWindowGenerationFromRec::setPathLibras(){
83 87
84 void ServiceWindowGenerationFromRec::setBackground(){ 88 void ServiceWindowGenerationFromRec::setBackground(){
85 if(this->transparency == 0) { //pega dicionario com BackGround opaco 89 if(this->transparency == 0) { //pega dicionario com BackGround opaco
86 - sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO,  
87 - this->path_libras, this->transparency);  
88 - } else {  
89 - if(this->transparency == 1) { //pega dicionario com BackGround transparente  
90 - sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO,  
91 - this->path_libras, this->transparency);  
92 - } 90 + char* dicPath;
  91 + dicPath = getenv("DIC_LIBRAS");
  92 + if(dicPath != NULL)
  93 + sincronizador = new Synchronizer(dicPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  94 + else
  95 + sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  96 +
  97 + } else if(this->transparency == 1) { //pega dicionario com BackGround transparente
  98 + char* dicTPath;
  99 + dicTPath = getenv("DICTRANSP_LIBRAS");
  100 + if(dicTPath != NULL)
  101 + sincronizador = new Synchronizer(dicTPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  102 + else
  103 + sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
93 } 104 }
94 } 105 }
95 106
servico/src/serviceWindowGenerationFromSRT.cpp
@@ -17,7 +17,11 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo, @@ -17,7 +17,11 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathVideo,
17 vetor_pts = new vector<int64_t >(); 17 vetor_pts = new vector<int64_t >();
18 tradutor = new TradutorPortGlosa(); 18 tradutor = new TradutorPortGlosa();
19 extrator_factory = new ExtratorFactory(); 19 extrator_factory = new ExtratorFactory();
20 - setPathContents(); 20 + try{
  21 + setPathContents();
  22 + }catch(RuntimeException ex){
  23 + throw ServiceException(ex.getMessage());
  24 + }
21 running = true; 25 running = true;
22 finish = false; 26 finish = false;
23 DPRINTF("Done!\n"); 27 DPRINTF("Done!\n");
@@ -35,7 +39,11 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, in @@ -35,7 +39,11 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* pathSRT, in
35 vetor_pts = new vector<int64_t >(); 39 vetor_pts = new vector<int64_t >();
36 tradutor = new TradutorPortGlosa(); 40 tradutor = new TradutorPortGlosa();
37 extrator_factory = new ExtratorFactory(); 41 extrator_factory = new ExtratorFactory();
38 - setPathContents(); 42 + try{
  43 + setPathContents();
  44 + }catch(RuntimeException ex){
  45 + throw ServiceException(ex.getMessage());
  46 + }
39 running = true; 47 running = true;
40 finish = false; 48 finish = false;
41 DPRINTF("Done!\n"); 49 DPRINTF("Done!\n");
@@ -81,13 +89,20 @@ void ServiceWindowGenerationFromSRT::setPathLibras() { @@ -81,13 +89,20 @@ void ServiceWindowGenerationFromSRT::setPathLibras() {
81 89
82 void ServiceWindowGenerationFromSRT::setBackground() { 90 void ServiceWindowGenerationFromSRT::setBackground() {
83 if(this->transparency == 0) { //pega dicionario com BackGround opaco 91 if(this->transparency == 0) { //pega dicionario com BackGround opaco
84 - sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO,  
85 - this->path_libras, this->transparency);  
86 - } else {  
87 - if(this->transparency == 1) { //pega dicionario com BackGround transparente  
88 - sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO,  
89 - this->path_libras, this->transparency);  
90 - } 92 + char* dicPath;
  93 + dicPath = getenv("DIC_LIBRAS");
  94 + if(dicPath != NULL)
  95 + sincronizador = new Synchronizer(dicPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  96 + else
  97 + sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  98 +
  99 + } else if(this->transparency == 1) { //pega dicionario com BackGround transparente
  100 + char* dicTPath;
  101 + dicTPath = getenv("DICTRANSP_LIBRAS");
  102 + if(dicTPath != NULL)
  103 + sincronizador = new Synchronizer(dicTPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  104 + else
  105 + sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
91 } 106 }
92 } 107 }
93 108
servico/src/serviceWindowGenerationFromText.cpp
@@ -12,7 +12,11 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile, @@ -12,7 +12,11 @@ ServiceWindowGenerationFromText::ServiceWindowGenerationFromText(char* pathFile,
12 vetor_pts = new vector<int64_t >(); 12 vetor_pts = new vector<int64_t >();
13 tradutor = new TradutorPortGlosa(); 13 tradutor = new TradutorPortGlosa();
14 extrator_factory = new ExtratorFactory(); 14 extrator_factory = new ExtratorFactory();
15 - setPathContents(); 15 + try{
  16 + setPathContents();
  17 + }catch(RuntimeException ex){
  18 + throw ServiceException(ex.getMessage());
  19 + }
16 running = true; 20 running = true;
17 finish = false; 21 finish = false;
18 DPRINTF("Done!\n"); 22 DPRINTF("Done!\n");
@@ -35,7 +39,7 @@ void ServiceWindowGenerationFromText::setPathContents() { @@ -35,7 +39,7 @@ void ServiceWindowGenerationFromText::setPathContents() {
35 ifstream conf_file(PATH_CONF_FILE, ifstream::binary); 39 ifstream conf_file(PATH_CONF_FILE, ifstream::binary);
36 parsingSuccessful = reader.parse(conf_file, root); 40 parsingSuccessful = reader.parse(conf_file, root);
37 if(!parsingSuccessful){ 41 if(!parsingSuccessful){
38 - throw ServiceException("Fail to parsing param.json"); 42 + throw new RuntimeException("Fail to parsing param.json");
39 } 43 }
40 string attr = root.get("storage", PATH_VBOX_UPLOADS).asString(); 44 string attr = root.get("storage", PATH_VBOX_UPLOADS).asString();
41 this->path_contents = new char[MAX_SIZE_PATH]; 45 this->path_contents = new char[MAX_SIZE_PATH];
@@ -56,14 +60,22 @@ void ServiceWindowGenerationFromText::setPathLibras() { @@ -56,14 +60,22 @@ void ServiceWindowGenerationFromText::setPathLibras() {
56 } 60 }
57 61
58 void ServiceWindowGenerationFromText::setBackground() { 62 void ServiceWindowGenerationFromText::setBackground() {
59 - if(this->transparency == 0) { //pega dicionario com BackGround opaco  
60 - sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO,  
61 - this->path_libras, this->transparency);  
62 - } else {  
63 - if(this->transparency == 1) { //pega dicionario com BackGround transparente  
64 - sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO,  
65 - this->path_libras, this->transparency);  
66 - } 63 + if(this->transparency == 0) { //pega dicionario com BackGround opaco
  64 + char* dicPath;
  65 + dicPath = getenv("DIC_LIBRAS");
  66 + if(dicPath != NULL)
  67 + sincronizador = new Synchronizer(dicPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  68 + else
  69 + sincronizador = new Synchronizer(BASEDIR, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  70 +
  71 + } else if(this->transparency == 1) { //pega dicionario com BackGround transparente
  72 + char* dicTPath;
  73 + dicTPath = getenv("DICTRANSP_LIBRAS");
  74 + if(dicTPath != NULL)
  75 + sincronizador = new Synchronizer(dicTPath, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  76 + else{
  77 + sincronizador = new Synchronizer(BASEDIRTRANSP, EXTENSAO_DICIONARIO, this->path_libras, this->transparency);
  78 + }
67 } 79 }
68 } 80 }
69 81