public void SetRecognitionData(RecognitionData inputData, TranslationRecognitionData outputData)
        {
            if (inputData != null)
            {
                UpdateTextBox(this.dictationTextBlock, inputData);
            }

            if (outputData?.FirstTranslationText != null)
            {
                UpdateTextBox(this.firstTranslationTextBlock, outputData.FirstTranslationText);
            }

            if (outputData?.SecondTranslationText != null)
            {
                UpdateTextBox(this.secondTranslationTextBlock, outputData.SecondTranslationText);
            }
        }
Esempio n. 2
0
        private void TranslationLanguagesChanged(TranslationRecognitionData outputData)
        {
            switch (SpeechExplorerState)
            {
            case SpeechExplorerState.Initial:
            case SpeechExplorerState.SpeechToText:
                this.speechToTextWithTranslation.SetRecognitionData(this.speechToTextView.GetRecognizedData(), null);
                SpeechExplorerState = SpeechExplorerState.SpeechToTextWithTranslation;
                break;

            case SpeechExplorerState.SpeechToTextWithTranslation:

                if (!string.IsNullOrEmpty(outputData?.FirstTranslationText?.Text))
                {
                    string text     = outputData.FirstTranslationText.Text;
                    string language = outputData.FirstTranslationText.Language?.Name;
                    if (!Regex.IsMatch(text, @"[()]"))
                    {
                        outputData.FirstTranslationText.Text           = language != null ? $"({language}) {text}" : string.Empty;
                        outputData.FirstTranslationText.HighlightStyle = true;
                    }
                }

                if (!string.IsNullOrEmpty(outputData?.SecondTranslationText?.Text))
                {
                    string text     = outputData.SecondTranslationText.Text;
                    string language = outputData.SecondTranslationText.Language?.Name;
                    if (!Regex.IsMatch(text, @"[()]"))
                    {
                        outputData.SecondTranslationText.Text           = language != null ? $"({language}) {text}" : string.Empty;
                        outputData.SecondTranslationText.HighlightStyle = true;
                    }
                }
                this.speechToTextWithTranslation.SetRecognitionData(null, outputData);
                break;
            }

            this.targetLanguagesListView.IsEnabled = FirstTranslationLanguage == null || SecondTranslationLanguage == null;
        }