示例#1
0
 public void Speak(string text, float speed, float pitch, Button btn, string msg)
 {
     if (!string.IsNullOrWhiteSpace(text))
     {
         _Speed  = speed;
         _Pitch  = pitch;
         _btn    = btn;
         _msg    = msg;
         toSpeak = text;
         if (speaker == null)
         {
             speaker = new TextToSpeech(MainActivity.Instance, this);
         }
         else
         {
             if (speaker.IsSpeaking)
             {
                 speaker.Stop();
             }
             //每次传进来的按钮可能不一样
             //speaker.SetOnUtteranceProgressListener(new ttsUtteranceListener(_btn, _msg));
             //speaker.SetOnUtteranceCompletedListener(this);
             //speaker.SetLanguage(Java.Util.Locale.Us);//设置语言
             speaker.SetPitch(_Pitch);      //音高
             speaker.SetSpeechRate(_Speed); //设置的语速
             speaker.Speak(toSpeak, QueueMode.Flush, null, "UniqueID");
         }
     }
 }
示例#2
0
        public void Speak(string text, bool force = false)
        {
            m_text = text;

            m_textToSpeech.Stop();

            m_force = force;
            if (!Sound && !force)
            {
                return;
            }

            Console.WriteLine("Speak TTS {0} {1} {2} --> {3}. Available: {4}",
                              m_language, SpeechRate, m_textToSpeech.Language, text,
                              m_textToSpeech.IsLanguageAvailable(m_language));
            m_textToSpeech.SetLanguage(m_language);
            m_textToSpeech.SetSpeechRate(SpeechRate);
            m_textToSpeech.SetPitch(PitchMultiplier);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            { // 5.0, API 21
                string utteranceId = m_text.GetHashCode() + "";
                m_textToSpeech.Speak(m_text, QueueMode.Flush, null, utteranceId);
            }
            else
            {
                m_textToSpeech.Speak(m_text, QueueMode.Flush, null);
            }
        }
示例#3
0
        // Interface method required for IOnInitListener
        void TextToSpeech.IOnInitListener.OnInit(OperationResult status)
        {
            // if we get an error, default to the default language
            if (status == OperationResult.Error)
            {
                textToSpeech.SetLanguage(Java.Util.Locale.Default);
            }
            // if the listener is ok, set the lang
            if (status == OperationResult.Success)
            {
                textToSpeech.SetLanguage(lang);
            }


            if ((current_dir != -1) && (current_file != -1))
            {
                string a = string.Format("Continuing the book from folder {0}, chapter {1}", current_dir, current_file + 1);
                textToSpeech.Speak(a, QueueMode.Flush, null);
                Task.Delay(3500).Wait();

                StopPlayer();
                filePath = files[current_file].FullName;
                AddTxt(filePath);

                StartPlayerAsync();
            }
        }
示例#4
0
 public void OnInit([GeneratedEnum] OperationResult status)
 {
     if (status.Equals(OperationResult.Success))
     {
         speaker.Speak(toSpeak, QueueMode.Flush, null, null);
     }
 }
示例#5
0
 public void OnInit([GeneratedEnum] OperationResult status)
 {
     if (status.Equals(OperationResult.Success))
     {
         speaker.Speak(toSpeak, QueueMode.Flush, new Dictionary <string, string>());
     }
 }
示例#6
0
        private void Speak()
        {
            if (!ready)
            {
                return;
            }

            if (currentSpeech == previousSpeech && speaking)
            {
                speaker.Stop();
                speaking = false;
            }
            else
            {
                // Because Android is stupid and breaking changes are great fun
                if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                {
                    speaker.Speak(new Java.Lang.String(currentSpeech), QueueMode.Flush, null, currentSpeech);
                }
                else
                {
#pragma warning disable CS0618 // Type or member is obsolete
                    speaker.Speak(currentSpeech, QueueMode.Flush, null);
#pragma warning restore CS0618 // Type or member is obsolete
                }
                speaking = true;
            }
        }
示例#7
0
        public void Speak(string text)
        {
            _toSpeak = text;
            if (_speaker == null)
            {
                //The first time that Speak() is called, the TextToSpeech instance will be created
                // and initialized; and  then the _speaker.Speak() line in the OnInit() method will
                // be called to actually do the speaking.

                Context ctx = ((Application.Current as CodeBrixApplication)?
                               .PlatformConfiguration as AndroidPlatformConfigBase)?
                              .MainActivityContext
                              ?? throw new InvalidOperationException("Could not retrieve a valid Context.");

                Debug.WriteLine("creating speaker");
                _speaker = new TextToSpeech(ctx, this);  //After initialization this.OnInit() will be called.
            }
            else
            {
                //Subsequent times that Speak() is called, the _speaker will already be created and
                // initialized, so this code will be executed.

                _uniqueUtteranceId = Guid.NewGuid().ToString();
                _speaker.Speak(_toSpeak, QueueMode.Flush, Bundle.Empty, _uniqueUtteranceId);
                Debug.WriteLine("spoke " + _toSpeak);
            }
        }
示例#8
0
        private void BtnSpeak_Click(object sender, EventArgs e)
        {
            //ttsClient.Speak("김프로님 준비하십시요",QueueMode.Add,null);
            //ttsClient.Speak("전방에 과속 방지턱이 있습니다", QueueMode.Add, null);
            //ttsClient.Speak("영원히 당신만을 사랑합니다", QueueMode.Add, null);
            //ttsClient.Speak("How are you", QueueMode.Add, null);
            //ttsClient.Speak("I love you forever", QueueMode.Add, null);
            ttsClient.Speak("아이 러브 유 포에버", QueueMode.Add, null);



            //Thread.Sleep(8000);

            ttsClient.SetLanguage(Java.Util.Locale.English);
            ttsClient.Speak("How are you", QueueMode.Add, null);
            ttsClient.Speak("I love you forever", QueueMode.Add, null);
            //Thread.Sleep(5000);

            ttsClient.SetLanguage(Java.Util.Locale.China);
            ttsClient.Speak("我永远只爱你一个人.", QueueMode.Add, null);
            //Thread.Sleep(3000);

            ttsClient.SetLanguage(Java.Util.Locale.Germany);
            ttsClient.Speak("Ich liebe dich nur für immer.", QueueMode.Add, null);
        }
示例#9
0
 /// <summary>
 ///     Implementation for <see cref="TextToSpeech.IOnInitListener.OnInit" />.
 /// </summary>
 /// <param name="status">
 ///     The status.
 /// </param>
 public void OnInit(OperationResult status)
 {
     if (status.Equals(OperationResult.Success))
     {
         var p = new Dictionary <string, string>();
         _speaker.Speak(_toSpeak, QueueMode.Flush, p);
     }
 }
 public void OnInit([GeneratedEnum] OperationResult status)
 {
     if (status.Equals(OperationResult.Success))
     {
         var p = new Dictionary <string, string>();
         Speaker.Speak(this.CurrentLearningModel.Value, QueueMode.Flush, p);
     }
 }
 void TextToSpeech.IOnInitListener.OnInit(OperationResult status)
 {
     if (status.Equals(OperationResult.Success))
     {
         var p = new Dictionary <string, string>();
         speaker.Speak(toSpeak, QueueMode.Flush, null, null);
     }
 }
    // Update is called once per frame
    void OnReceiveAnything(OscMessage message)
    {
        Debug.Log("I GOT ONE!!!");


        timer++;
        Debug.Log("Recieved Message " + timer + " of " + messageno);

        if (timer >= messageno)
        {
            messageno = Random.Range(3, 9);


            if (Random.Range(0, 100) > 50)
            {
                if (u1)
                {
                    tts.dialogue = "User 1 leaves the stage";
                    u1           = false;
                }

                else
                {
                    tts.dialogue = "User 1 enters the stage";
                    u1           = true;
                    noone        = false;
                }
            }

            else
            {
                if (u2)
                {
                    tts.dialogue = "User 2 leaves the stage";
                    u2           = false;
                }

                else
                {
                    tts.dialogue = "User 2 enters the stage";
                    u2           = true;
                    noone        = false;
                }
            }



            tts.Speak();
            timer = 0;
        }
        if (!u1 && !u2)
        {
            tts.dialogue = "Where has everybody gone";
            tts.noone    = true;
            tts.Speak();
            noone = true;
        }
    }
        public void OnInit([GeneratedEnum] OperationResult status)
        {
            if (status.Equals(OperationResult.Success))
            {
                var p = new Dictionary <string, string> ();

                speaker.SetLanguage(Locale.French);
                speaker.Speak(toSpeak, QueueMode.Flush, p);
            }
        }
        /// <summary>
        ///     Implementation for <see cref="TextToSpeech.IOnInitListener.OnInit" />.
        /// </summary>
        /// <param name="status">
        ///     The status.
        /// </param>
        public void OnInit(OperationResult status)
        {
            if (status.Equals(OperationResult.Success))
            {
                var p = new Dictionary <string, string>();

#pragma warning disable CS0618 // Type or member is obsolete
                _speaker.Speak(_toSpeak, QueueMode.Flush, p);
#pragma warning restore CS0618 // Type or member is obsolete
            }
        }
示例#15
0
        /// <summary>
        /// Initiates the Android speaker to read the provided string
        /// </summary>
        /// <param name="Text"></param>
        private void TextToSpeech(string Text)
        {
            ToSpeak = Text;
            logger.Debug("Speaking: " + Text);
            if (Speaker == null)
            {
                Speaker = new TextToSpeech(this, this);
            }

            Speaker.Speak(Text, QueueMode.Flush, null, null);
        }
示例#16
0
 /// <summary>
 /// 텍스트 값 음성으로 내보내기
 /// </summary>
 /// <param name="text"></param>
 public void Speak(string text)
 {
     if (_speaker == null)
     {
         _speaker = new TextToSpeech(Application.Context, this);
     }
     else
     {
         _speaker.Speak(text, QueueMode.Add, null, null);
     }
 }
 public void Speech(string text)
 {
     _text = text;
     if (_speaker == null)
     {
         _speaker = new TextToSpeech(Forms.Context, this);
     }
     else
     {
         _speaker.Speak(_text, QueueMode.Flush, Bundle.Empty, null);
     }
 }
示例#18
0
 public void Speak(string text)
 {
     if (speech == null)
     {
         lastText = text;
         speech   = new TextToSpeech(Application.Context, this);
     }
     else
     {
         speech.Speak(text, QueueMode.Flush, new Dictionary <string, string>());
     }
 }
示例#19
0
 public void Speak(string text)
 {
     _text = text;
     if (_speaker == null)
     {
         _speaker = new TextToSpeech(_context, this);
     }
     else
     {
         _speaker.Speak(_text, QueueMode.Flush, null, "messageId");
     }
 }
 public void OnInit([GeneratedEnum] OperationResult status)
 {
     if (status.Equals(OperationResult.Success))
     {
         Debug.WriteLine("speaker init");
         speaker.Speak(toSpeak, QueueMode.Flush, null, null);
     }
     else
     {
         Debug.WriteLine("was quiet");
     }
 }
 public void ReadText(string text)
 {
     _textToRead = text;
     if (_speaker == null)
     {
         _speaker = new TextToSpeech(MainActivity.Instance, this);
     }
     else
     {
         _speaker.Speak(_textToRead, QueueMode.Flush, null, null);
     }
 }
示例#22
0
 public void Speak(string text)
 {
     toSpeak = text;
     if (speaker == null)
     {
         speaker = new TextToSpeech(Android.App.Application.Context, this);
     }
     else
     {
         speaker.Speak(toSpeak, QueueMode.Flush, null, null);
     }
 }
示例#23
0
 public void Speak(string text)
 {
     toSpeak = text;
     if (speaker == null)
     {
         speaker = new TextToSpeech(MainActivity.Instance, this, "com.google.android.tts");
     }
     else
     {
         speaker.Speak(toSpeak, QueueMode.Flush, null, null);
     }
 }
示例#24
0
 public void Speak(string text)
 {
     toSpeak = text;
     if (speaker == null)
     {
         speaker = new TextToSpeech(Forms.Context, this);
     }
     else
     {
         speaker.Speak(toSpeak, QueueMode.Flush, null, null);
     }
 }
示例#25
0
        void StartCore()
        {
            tts.Speak("叮咚", QueueMode.Flush, null);
            if (isIdentify && System.IO.File.Exists(ImagePath + nowLesson + ".dat"))                 //指纹识别
            // Enroll visitor with unknown identity
            //MyPerson probe = Enroll(ImagePath + "t1.BMP", "##Visitor##");
            {
                tv.Text = "开始识别。。。";
                MyPerson probe = Enroll(pics, "##Visitor##");
                Console.WriteLine("Identifying {0} in database of {1} persons...", probe.Name, database.Count);
                MyPerson match = Afis.Identify(probe, database).FirstOrDefault() as MyPerson;
                // Null result means that there is no candidate with similarity score above threshold
                if (match == null)
                {
                    Console.WriteLine("No matching person found.");
                    result.Text = "无匹配指纹!";
                    tts.Speak("不认识你", QueueMode.Flush, null);
                }
                else
                {
                    // Print out any non-null result
                    Console.WriteLine("Probe {0} matches registered person {1}", probe.Name, match.Name);


                    // Compute similarity score
                    float score = Afis.Verify(probe, match);
                    Console.WriteLine("Similarity score between {0} and {1} = {2:F3}", probe.Name, match.Name, score);
                    tv.Text = "识别完成。。。";
                    tts.Speak(match.Name, QueueMode.Flush, null);
                    judgeTime(match.Name);
                    result.Text = "身份:" + match.Name + "\n匹配分数:" + score;
                }
            }
            else if (xuehao != null)                 //指纹录入
            //database.Add(Enroll(ImagePath + "r1.BMP", xuehao));
            {
                database.Add(Enroll(pics, xuehao));
                xuehao = null;

                // Save the database to disk and load it back, just to try out the serialization
                Console.WriteLine("Saving database...");
                BinaryFormatter formatter = new BinaryFormatter();
                using (Stream stream = File.Open(ImagePath + nowLesson + ".dat", FileMode.OpenOrCreate))
                    formatter.Serialize(stream, database);

                isIdentify = true;
                tv.Text    = "指纹已录入,开始识别。。。";
            }
            else
            {
                //Toast.MakeText(Application.Context,"请先录入指纹",ToastLength.Short).Show();
            }
        }
示例#26
0
 public void Speech(string text)
 {
     _text = text;
     if (_speaker == null)
     {
         _speaker = new TextToSpeech(Forms.Context, this);
     }
     else
     {
         _speaker.Speak(_text, QueueMode.Flush, new Dictionary <string, string>());
     }
 }
示例#27
0
 public void Speak(string text, string language)
 {
     toSpeak = text;
     if (speaker == null)
     {
         speaker = new TextToSpeech(MainActivity.Instance, this);
     }
     else
     {
         speaker.Speak(toSpeak, QueueMode.Flush, null, null);
     }
 }
示例#28
0
 public void Speak(Context context, string text)
 {
     toSpeak = text;
     if (speaker == null)
     {
         speaker = new TextToSpeech(context, this);
     }
     else
     {
         var p = new Dictionary <string, string> ();
         speaker.Speak(toSpeak, QueueMode.Flush, p);
     }
 }
示例#29
0
 public void Speak(string text)
 {
     toSpeak = text;
     if (speaker == null)
     {
         speaker = new TextToSpeech(MainActivity.Instance, this);
     }
     else
     {
         speaker.Speak(toSpeak, QueueMode.Flush, null, null);
         //  Debug.WriteLine("spoke " + toSpeak);
     }
 }
        public void Speak(string text)
        {
            var c = Forms.Context;

            toSpeak = text;
            if (speaker == null)
            {
                speaker = new TextToSpeech(c, this);
            }
            var p = new Dictionary <string, string> ();

            speaker.Speak(toSpeak, QueueMode.Flush, p);
        }