Exemple #1
0
        public void Speak(string text)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();

            speechSynthesizer.SpeakUtterance(new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.DefaultSpeechRate,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = .5f,
                PitchMultiplier = 1.0f
            });
        }
        public void speak(string text)
        {
            var speechSinthesizer = new AVSpeechSynthesizer();
            var speechUterance    = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("es-ES"),
                Volume          = 0.5F,
                PitchMultiplier = 1.0F
            };

            speechSinthesizer.SpeakUtterance(speechUterance);
        }
        /// <summary>
        /// 文字列を読み上げます
        /// </summary>
        /// <param name="text">読み上げる文字列</param>
        public void Speak(string text)
        {
            var synthesizer = new AVSpeechSynthesizer();

            synthesizer.SpeakUtterance(
                new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("ja-JP"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            });
        }
Exemple #4
0
        public void Speak(string speakText)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();
            var speechUtterance   = new AVSpeechUtterance(speakText)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 2,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
        /// <summary>
        /// Set speaking a language
        /// </summary>
        /// <param name="language">speak language name</param>
        public void SetLanguage(string language)
        {
            switch (language)
            {
            case "Japanese":
                this.language = AVSpeechSynthesisVoice.FromLanguage("ja-JP");
                break;

            default:
                this.language = AVSpeechSynthesisVoice.FromLanguage("en-US");
                break;
            }
        }
        public void Speak(string text, string language)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();
            var speechUtterance   = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 2,
                Voice           = AVSpeechSynthesisVoice.FromLanguage(language),
                Volume          = 1f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
        public void Speak(string text)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();
            var speechUtterance   = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 3,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = volume,
                PitchMultiplier = pitch
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
Exemple #8
0
        /// <summary>
        /// Uses speech synthesis to say something.
        /// </summary>
        /// <param name="text">Text.</param>
        void Say(string text)
        {
            // Speak the current location.
            var utterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = .5f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(utterance);
        }
        private void SpeechText(string testedSpeech)
        {
            AVSpeechSynthesizer speech = new AVSpeechSynthesizer();

            AVSpeechUtterance speechUtterance = new AVSpeechUtterance(testedSpeech)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 2.0f,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 1.0f,
                PitchMultiplier = 1.0f
            };

            speech.SpeakUtterance(speechUtterance);
        }
Exemple #10
0
        public void TextToTalk(string text)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();

            var speechUtterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("pt-BR"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
        //french voice that will be used to read the subtitle (DetailTextLabel) property of the french phrases, stored currently in the table view's memory cache
        public void frenchPhraseBookAI(string textToSpeak)
        {
            AVSpeechSynthesizer frenchSpeech = new AVSpeechSynthesizer();

            AVSpeechUtterance frenchVoice = new AVSpeechUtterance(textToSpeak)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 2.2f,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("fr"),
                Volume          = 1.0f,
                PitchMultiplier = 1.0f
            };

            frenchSpeech.SpeakUtterance(frenchVoice);
        }
Exemple #12
0
        /// <summary>
        /// 实现 ITTS 接口方法
        /// 播放语音
        /// </summary>
        /// <param name="content"></param>
        public void Play(string content)
        {
            if (Check_InitTextToSpeech() == false)
            {
                return;
            }

            Task myTask = new Task(() =>
            {
                AVSpeechUtterance speechUtterance = new AVSpeechUtterance(content)
                {
                    Rate            = AVSpeechUtterance.MaximumSpeechRate / 3,
                    Voice           = AVSpeechSynthesisVoice.FromLanguage("zh-CN"),
                    Volume          = mVolume,
                    PitchMultiplier = mPitch,
                };

                speechUtterance.Rate = mRate;

                mSpeechSynthesizer.SpeakUtterance(speechUtterance);
            });

            myTask.ContinueWith((task) =>
            {
                if (task.IsFaulted == true)
                {
                    string msg = string.Empty;
                    if (task.Exception != null)
                    {
                        msg = "TTS Play 异常 : \r\n{0}".FormatWith(task.Exception.GetFullInfo());
                    }
                    else
                    {
                        msg = "TTS Play 异常 : ".FormatWith();
                    }

                    System.Diagnostics.Debug.WriteLine(msg);

                    // TODO iOS MyTTS 弹窗提示
                    //System.Threading.Tasks.Task.Run(() =>
                    //{
                    //    Looper.Prepare();
                    //    Toast.MakeText(((Activity)Xamarin.Forms.Forms.Context), msg, ToastLength.Long).Show();
                    //    Looper.Loop();
                    //});
                }
            });

            myTask.Start();
        }
Exemple #13
0
        public override void Speak(string text)
        {
            var synthesizer = new AVSpeechSynthesizer();

            var utterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.DefaultSpeechRate,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            synthesizer.SpeakUtterance(utterance);
        }
Exemple #14
0
        //AI speech
        public void AIEnglish(string textToSpeech, string accent, float speechRate, float volume, float pitchMultiplier)
        {
            AVSpeechSynthesizer speech = new AVSpeechSynthesizer();

            AVSpeechUtterance speechUtterance = new AVSpeechUtterance(textToSpeech)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / speechRate,
                Voice           = AVSpeechSynthesisVoice.FromLanguage(accent),
                Volume          = volume,
                PitchMultiplier = pitchMultiplier
            };

            speech.SpeakUtterance(speechUtterance);
        }
Exemple #15
0
            internal AVSpeechSynthesisVoice GetVoiceForLocaleLanguage()
            {
                var language = Language.GetInstalledLanguages().FirstOrDefault(x => x.Id.StartsWith(Language?.Id.ToLower()))?.Id ?? AVSpeechSynthesisVoice.CurrentLanguageCode;

                var voice = AVSpeechSynthesisVoice.FromLanguage(language);

                if (voice != null)
                {
                    return(voice);
                }

                Log.For(this).Error("Voice not found for language: " + language + ". Using default instead.");
                return(AVSpeechSynthesisVoice.FromLanguage(AVSpeechSynthesisVoice.CurrentLanguageCode));
            }
        //english voice that notifies the end user of background executions
        public void englishAIBackground(string textToSpeak)
        {
            AVSpeechSynthesizer englishSpeech = new AVSpeechSynthesizer();

            AVSpeechUtterance englishVoice = new AVSpeechUtterance(textToSpeak)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 2.2f,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 1.0f,
                PitchMultiplier = 1.0f
            };

            englishSpeech.SpeakUtterance(englishVoice);
        }
Exemple #17
0
        private void AISpeech(string textSpeak, float speechRate)
        {
            AVSpeechSynthesizer speech = new AVSpeechSynthesizer();

            AVSpeechUtterance speechUtterance = new AVSpeechUtterance(textSpeak)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / speechRate,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 1.0f,
                PitchMultiplier = 1.0f
            };

            speech.SpeakUtterance(speechUtterance);
        }
        public void ReadText(string text)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();
            //Voice = AVSpeechSynthesisVoice.FromLanguage("fr-FR")
            var speechUtterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
Exemple #19
0
        public void Speak(string text, bool queue = false, CrossLocale?crossLocale = default(CrossLocale?), float?pitch = default(float?), float?speakRate = default(float?), float?volume = default(float?))
        {
            _isSpeaking = true;
            var speechRate = UIDevice.CurrentDevice.CheckSystemVersion(8, 0) ? 8 : 4;

            var speechUtterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / speechRate,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            _speechSynthesizer.SpeakUtterance(speechUtterance);
        }
Exemple #20
0
        public void Speak(string text)
        {
            _isSpeaking = true;
            //var speechRate = UIDevice.CurrentDevice.CheckSystemVersion(8, 0) ? 8 : 4;
            var speechUtterance = new AVSpeechUtterance(text)
            {
                //Rate = AVSpeechUtterance.MaximumSpeechRate / speechRate,
                Rate            = AVSpeechUtterance.DefaultSpeechRate,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            _speechSynthesizer.SpeakUtterance(speechUtterance);
        }
        partial void btnSpeak_TouchUpInside(UIButton sender)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();
            var button            = (UIButton)sender;

            var speechUtterance = new AVSpeechUtterance(button.TitleLabel.Text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
        public async Task SpeakAsync(string text)
        {
            tcsUtterance = new TaskCompletionSource <bool>();

            synthesizer.DidFinishSpeechUtterance += OnFinishedSpeechUtterance;
            utterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 3,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 1.0f,
                PitchMultiplier = 1.0f,
            };
            synthesizer.SpeakUtterance(utterance);
            await tcsUtterance.Task;
        }
Exemple #23
0
        void Speak(string text)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();

//                        var voices = AVSpeechSynthesisVoice.GetSpeechVoices ();

            var speechUtterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("tr-TR"),
                Volume          = volume,
                PitchMultiplier = pitch
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
        /// <summary>
        /// The speak.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="language">The language.</param>
        public void Speak(string text, string language = DEFAULT_LOCALE)
        {
            var speechSynthesizer = new AVSpeechSynthesizer();

            var voice = AVSpeechSynthesisVoice.FromLanguage(language) ?? AVSpeechSynthesisVoice.FromLanguage(DEFAULT_LOCALE);

            var speechUtterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage(language),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
        public void Speak(string text_to_speak)
        {
            AVSpeechSynthesizer speechSynthesizer = new AVSpeechSynthesizer();

            AVSpeechUtterance speechUtterance = new AVSpeechUtterance(text_to_speak)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);

            return;
        }
Exemple #26
0
        public void Speak(string text)
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                var speechSynthesizer = new AVSpeechSynthesizer();
                var speechUtterance   = new AVSpeechUtterance(text)
                {
                    Rate            = AVSpeechUtterance.MaximumSpeechRate / 3,
                    Voice           = AVSpeechSynthesisVoice.FromLanguage(CultureInfo.CurrentCulture.Name),
                    Volume          = 0.5f,
                    PitchMultiplier = 1.0f
                };

                speechSynthesizer.SpeakUtterance(speechUtterance);
            }
        }
        private AVSpeechSynthesisVoice GetVoiceForLocaleLanguage(CrossLocale?crossLocale)
        {
            var localCode = crossLocale.HasValue &&
                            !string.IsNullOrWhiteSpace(crossLocale.Value.Language) ?
                            crossLocale.Value.Language :
                            AVSpeechSynthesisVoice.CurrentLanguageCode;

            var voice = AVSpeechSynthesisVoice.FromLanguage(localCode);

            if (voice == null)
            {
                Console.WriteLine("Locale not found for voice: " + localCode + " is not valid. Using default.");
                voice = AVSpeechSynthesisVoice.FromLanguage(AVSpeechSynthesisVoice.CurrentLanguageCode);
            }

            return(voice);
        }
        public Task Speak(string text)
        {
            return(new Task(() =>
            {
                var speechSynthesizer = new AVSpeechSynthesizer();

                var speechUtterance = new AVSpeechUtterance(text)
                {
                    Rate = AVSpeechUtterance.MaximumSpeechRate / 2.5f,
                    Voice = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                    Volume = 0.5f,
                    PitchMultiplier = 1.0f
                };

                speechSynthesizer.SpeakUtterance(speechUtterance);
            }));
        }
        public void Speak(string text)
        {
            if (String.IsNullOrEmpty(text))
            {
                return;
            }
            var speechSynthesizer = new AVSpeechSynthesizer();

            var speechUtterance = new AVSpeechUtterance(text)
            {
                Rate            = AVSpeechUtterance.MaximumSpeechRate / 4,
                Voice           = AVSpeechSynthesisVoice.FromLanguage("en-US"),
                Volume          = 0.5f,
                PitchMultiplier = 1.0f
            };

            speechSynthesizer.SpeakUtterance(speechUtterance);
        }
Exemple #30
0
        public void SetLanguage(string sLanguage)
        {
            switch (sLanguage)
            {
            case "Japanese":
                this.language = AVSpeechSynthesisVoice.FromLanguage("ja-JP");
                break;

            case "Korean":
                this.language = AVSpeechSynthesisVoice.FromLanguage("ko-KR");
                break;

            case "Indonesian":
                this.language = AVSpeechSynthesisVoice.FromLanguage("id-ID");
                break;

            default:
                this.language = AVSpeechSynthesisVoice.FromLanguage("en-US");
                break;
            }
        }