Example #1
0
        private void OnSpeechPlClicked()
        {
            if (TranslationsState?.Value?.BaseTranslation.BaseTerm is null)
            {
                return;
            }

            var utterance = new SpeechSynthesisUtterance
            {
                Text   = TranslationsState.Value.BaseTerm.Name,
                Lang   = Const.PlLangSpeechCode, // BCP 47 language tag
                Pitch  = 1.0,                    // 0.0 ~ 2.0 (Default 1.0)
                Rate   = 1.0,                    // 0.1 ~ 10.0 (Default 1.0)
                Volume = 1.0                     // 0.0 ~ 1.0 (Default 1.0)
            };

            SpeechSynthesis?.Speak(utterance);
        }
Example #2
0
        private void OnSpeechEnClicked()
        {
            if (TranslationsState?.Value?.BaseTranslation.Translation is null)
            {
                return;
            }

            var utterance = new SpeechSynthesisUtterance
            {
                Text   = TranslationsState.Value.Translation.Name,
                Lang   = Func.GetLangSpeech(TranslationsState.Value.Translation.LanguageId), // BCP 47 language tag
                Pitch  = 1.0,                                                                // 0.0 ~ 2.0 (Default 1.0)
                Rate   = 1.0,                                                                // 0.1 ~ 10.0 (Default 1.0)
                Volume = 1.0                                                                 // 0.0 ~ 1.0 (Default 1.0)
            };

            SpeechSynthesis?.Speak(utterance);
        }