Ejemplo n.º 1
0
        /// <summary>
        /// Enqueues an utterance to be spoken with using specific parameters
        /// </summary>
        /// <param name="speechUtterance">A chunk of text to be spoken, along with parameters that affect its speech.</param>
        public static void Speak(SpeechUtterance speechUtterance)
        {
            var voiceIdentifier = speechUtterance.Voice == null ? string.Empty : speechUtterance.Voice.Identifier;

            TTS_iOS.Speak(speechUtterance.SpeechString, speechUtterance.PitchMultiplier,
                          speechUtterance.PreUtteranceDelay, speechUtterance.PostUtteranceDelay, speechUtterance.SpeechRate,
                          voiceIdentifier, speechUtterance.Volume);
        }
Ejemplo n.º 2
0
        private ReadOnlyCollection <ISpeechSynthesisVoice> InitializeVoices()
        {
            var availableVoicesCount = TTS_iOS.GetNumberOfAvailableVoices();
            var availableVoices      = new ISpeechSynthesisVoice[availableVoicesCount];

            for (var voiceIndex = 0; voiceIndex < availableVoicesCount; voiceIndex++)
            {
                var identifier = TTS_iOS.GetVoiceIdentifier(voiceIndex);
                var name       = TTS_iOS.GetVoiceName(voiceIndex);
                var language   = TTS_iOS.GetVoiceLanguage(voiceIndex);
                var quality    = TTS_iOS.GetVoiceQuality(voiceIndex);
                availableVoices[voiceIndex] =
                    new SpeechSynthesisVoice(identifier, name, language, (VoiceQuality)quality);
            }

            return(new ReadOnlyCollection <ISpeechSynthesisVoice>(availableVoices));
        }
Ejemplo n.º 3
0
 private void SetupCallbacks()
 {
     TTS_iOS.SetupCallbacks(OnSpeechCancelledCallback, OnSpeechContinuedCallback,
                            OnSpeechFinishedCallback, OnSpeechPausedCallback, OnSpeechStartedCallback, OnWillSpeakCallback);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a voice object for the specified language and locale.
        /// </summary>
        /// <param name="language">A BCP 47 code specifying language and locale for a voice.</param>
        /// <returns>Returns null if no voice available for the specified language</returns>
        public static ISpeechSynthesisVoice GetVoiceForLanguage(string language)
        {
            var voiceId = TTS_iOS.GetVoiceIdentifierFromLanguageCode(language);

            return(AllAvailableVoices.FirstOrDefault(voice => voice.Identifier == voiceId));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Stops all speech at the specified boundary constraint.
 /// </summary>
 /// <param name="speechBoundary">A constant describing whether speech should stop immediately or only after finishing the word currently being spoken.</param>
 /// <returns>true if speech has stopped, or false otherwise.</returns>
 public static bool Stop(SpeechBoundary speechBoundary)
 {
     return(TTS_iOS.StopSpeaking(speechBoundary));
 }
Ejemplo n.º 6
0
 /// <summary>
 ///  Stops all speech at default boundary constraints.
 /// </summary>
 /// <returns>true if speech has stopped, or false otherwise.</returns>
 public static bool Stop()
 {
     return(TTS_iOS.StopSpeaking(DefaultSpeechBoundaryForStop));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Pauses speech at the specified boundary constraint.
 /// </summary>
 /// <param name="speechBoundary">A constant describing whether speech should pause immediately or only after finishing the word currently being spoken.</param>
 /// <returns>true if speech has paused, or false otherwise.</returns>
 public static bool Pause(SpeechBoundary speechBoundary)
 {
     return(TTS_iOS.PauseSpeaking(speechBoundary));
 }
Ejemplo n.º 8
0
 /// <summary>
 ///  Pauses speech at default boundary constraints.
 /// </summary>
 /// <returns>true if speech has paused, or false otherwise.</returns>
 public static bool Pause()
 {
     return(TTS_iOS.PauseSpeaking(DefaultSpeechBoundaryForPause));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Continues speech from the point at which it left off.
 /// </summary>
 /// <returns>true if speech has continued, or false otherwise.</returns>
 public static bool Continue()
 {
     return(TTS_iOS.ContinueSpeaking());
 }