2014-01-21 2 views
0

all. 어떤 도움을 주셔서 감사합니다. 텍스트 - 투 -의 플립을 사용하여, 나는 텍스트 파일은 파일에 텍스트 음성 변환을 수행 걸릴 것 "Windows Form에 VC++"에서 일부 코드를 작성했습니다 : 여기 함수가 호출되기 전에 모든 코드가 실행되지 않습니다.

내 문제입니다 음성 알고리즘. 텍스트가 MS "말하기"기능을 사용하여 발성 된 후 텍스트 상자에 몇 가지 헤더 정보와 내용을 기록해야합니다. 그 후 count 변수가 업데이트되고 다른 방향에서 다른 음성을 합성하는 다른 함수가 호출됩니다.

문제는 머리글 정보와 음성 단어가 textBox에 쓰여지기 전에 두 번째 기능이 호출되고 일단 끝나면 그 정보로 textBox를 채우는 것입니다. 만. 첫 번째 정보는 textBox에 기록되지 않습니다.

무엇이 원인 일 수 있습니까 ?? 두 번째 함수에 대한 호출을 여러 가지 다른 방법으로 지연 시키려고했지만 성공하지 못했습니다. 나는 밖에서 많은 도움을 얻을 수있을 것입니다. 이 두 가지 코드 단편을이 질문에 사용합니다. 미리 감사 드리며 정말로 도움이되기를 바랍니다. 다시 한번 감사드립니다. 두 번째 호출로

첫 번째 코드 :

for(ClickCount_ATCText = 0; ClickCount_ATCText < FilesSelected_ATC_A; ClickCount_ATCText++) 
        { 
        SetChannelVolumeLevel(ATC_OverLord); 
        PlaySound(TEXT("c:\\SSL_Sound\\AC_AudioBackground.wav"), NULL, SND_FILENAME); 
        //GetWavFilePath(ATC_OverLord); 

        //if(ClickCount_ATCText > (FilesSelected_ATC_A - 1)) 
        //{ 
         //ClickCount_ATCText = 0; 
        //}// End DataLink if statement 

        SpeechSynthesizer^ Vocalize  = gcnew SpeechSynthesizer();             //Create a voice synthesizer instance. 

        string TTS_TxtPath    = ATC_TxtFiles[ClickCount_ATCText];            //The following two lines converts the standard string in to a system string for use in the StreamReader function. 
        String^ TTS_FilePath   = gcnew String(TTS_TxtPath.c_str());   

        StreamReader^ FileRead   = gcnew StreamReader(TTS_FilePath);            //Get the text file from the path identified. 
        String^ AutoTTSFileRead   = FileRead->ReadToEnd();              //Read the entire file and store the text characters in the string variable "AutoTTSFileRead".        

        Vocalize->Speak(AutoTTSFileRead);                    //Vocalize the text in the textbox. 

        //Sleep(3000);                         //Pause half a second before displaying the text. Not needed, but kept for reference. 

        //* The 6 lines code below provides a timestamp and formats the output of the data link message. 
        TextToSpeechTextbox->Text   = "       Data Link Message \r\n \r\n"; 
        time(&WhatTimeIsIt); 
        String^ strNew      = gcnew String(ctime(&WhatTimeIsIt)); 
        TextToSpeechTextbox->Text   = TextToSpeechTextbox->Text + "Timestamp: " + strNew + "\r\n"; 
        TextToSpeechTextbox->Text   = TextToSpeechTextbox->Text + "\r\n"; 
        TextToSpeechTextbox->Text   = TextToSpeechTextbox->Text + "Message: " + AutoTTSFileRead + "\r\n"; //Display the speech data in the text box.    

        ClickCount_ATCText++; 
        NE_STT_SLL_Function(); 

        }//End for loop 

**NE_STT_SLL_Function:** 

void NE_STT_SLL_Function() 
     { 
      //Sleep(3000); 

      SetChannelVolumeLevel(North_East);        //Set the volume level for this SSL and zero the rest. 

      PlaySound(TEXT("c:\\SSL_Sound\\AC_AudioBackground.wav"), NULL, SND_FILENAME);         //Play a snippet of radio noise in the background before sythesizing 

      if(ClickCount_NorthEastText >= (FilesSelected_NE - 1)) 
       { 
       ClickCount_NorthEastText = 0; 
       }// End DataLink if statement 

      SpeechSynthesizer^ Vocalize  = gcnew SpeechSynthesizer();             //Create a voice synthesizer instance. 

      string TTS_TxtPath    = NorthEast_TxtFiles[ClickCount_NorthEastText];         //The following two lines converts the standard string in to a system string for use in the StreamReader function. 
      String^ TTS_FilePath   = gcnew String(TTS_TxtPath.c_str());   

      StreamReader^ FileRead   = gcnew StreamReader(TTS_FilePath);            //Get the text file from the path identified. 
      String^ AutoTTSFileRead   = FileRead->ReadToEnd();              //Read the entire file and store the text characters in the string variable "AutoTTSFileRead".        

      Vocalize->Speak(AutoTTSFileRead);                    //Vocalize the text in the textbox. 

      //* The 6 lines code below provides a timestamp and formats the output of the data link message. 
      TextToSpeechTextbox->Text   = "     (NE) Sound Source Location Message \r\n \r\n"; 
      time(&WhatTimeIsIt); 
      String^ strNew      = gcnew String(ctime(&WhatTimeIsIt)); 
      TextToSpeechTextbox->Text   = TextToSpeechTextbox->Text + "Timestamp: " + strNew + "\r\n"; 
      TextToSpeechTextbox->Text   = TextToSpeechTextbox->Text + "\r\n"; 
      TextToSpeechTextbox->Text   = TextToSpeechTextbox->Text + "Message: " + AutoTTSFileRead + "\r\n"; //Display the speech data in the text box. 

      ClickCount_NorthEastText++; //Increment array index value. 
      return; 

      }//End NE STT SSL function 

답변

1

창 Forms 응용 프로그램은 메시지 루프를 기반으로합니다. messagge 루프에 실행할 시간이 없으면 아무 것도 표시되거나 새로 고쳐지지 않습니다. for-loop에서 텍스트를 변경하면 마지막 루프 만 표시됩니다. 또한 Text2Speach는 일반적으로 asynchonus라는 점에 유의하십시오. 따라서 텍스트를 읽지 않아도 함수가 반환됩니다. 따라서 완료된 이벤트를 사용하여 작업을 처리하십시오 ... (SpeechSynthesizer::SpeakCompleted)

또한 Windows UI 응용 프로그램에서 절전 모드 또는 기타 긴밀한 루프를 사용하지 마십시오. 타이머 (Windows :: Forms :: Timer)를 사용하거나 이벤트 기반 처리를 사용하는 것을 고려하십시오!

관련 문제