コード例 #1
0
    private void InitaliseTTS()
    {
        SpeechEngine.AddCallback(() =>
        {
            locales = Locale.AllLocales;
            locales = locales.OrderBy(go => go.Informations).ToArray();
            voices  = SpeechEngine.AvaillableVoices;
            voices  = voices.OrderBy(go => go.Name).ToArray();
            engines = SpeechEngine.AvailableEngines;
            engines = engines.OrderBy(go => go.Label).ToArray();

            localeDropdown.AddOptions(locales.Select(elem => elem.Informations).ToList());
            voicesDropdown.AddOptions(voices.Select(elem => elem.Name).ToList());
            engineDropdown.AddOptions(engines.Select(elem => elem.Label).ToList());

            localeDropdown.onValueChanged.AddListener(value =>
            {
                SpeechEngine.SetLanguage(locales[value]);
                voicesDropdown.ClearOptions();
                voices = SpeechEngine.AvaillableVoices;
                voicesDropdown.AddOptions(voices.Select(elem => elem.Name).ToList());
            });

            voicesDropdown.onValueChanged.AddListener(value =>
            {
                SpeechEngine.SetVoice(voices[value]);
            });

            engineDropdown.onValueChanged.AddListener(value =>
            {
                SpeechEngine.SetEngine(engines[value]);
            });
        });
    }
コード例 #2
0
        public void SpeechEngine_SpeakOneTime()
        {
            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 0;

                SpeechEngine.Start(settings);

                var phrase = Phrase.PhoneText("This is a one-time phrase.");

                phrase.IsOneTime = true;

                PlayAudio(SpeechEngine.SpeakToFile(phrase));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #3
0
        public void SpeechEngine_VerifyCache()
        {
            DeleteFolder();

            try
            {
                var    settings = new SpeechEngineSettings();
                string path1;
                string path2;

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 0;

                SpeechEngine.Start(settings);

                path1 = SpeechEngine.SpeakToFile(Phrase.PhoneText("Hello cruel world!"));
                path2 = SpeechEngine.SpeakToFile(Phrase.PhoneText("Hello cruel world!"));

                Assert.AreEqual(path1, path2);
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #4
0
    private void InitSpeechEngine()
    {
        SpeechEngine.AddCallback(() =>
        {
            locales = Locale.AllLocales; // SpeechEngine.AvailableLocales;
            voices  = SpeechEngine.AvaillableVoices;
            engines = SpeechEngine.AvailableEngines;

            localesDropdown.AddOptions(locales.Select(elem => elem.Informations).ToList());
            voicesDropdown.AddOptions(voices.Select(elem => elem.Name).ToList());
            enginesDropdown.AddOptions(engines.Select(elem => elem.Label).ToList());

            SpeechEngine.AddListeners(null, pitchSlider, speechRateSlider);

            localesDropdown.onValueChanged.AddListener(value =>
            {
                SpeechEngine.SetLanguage(locales[value]);
                voicesDropdown.ClearOptions();
                voices = SpeechEngine.AvaillableVoices;
                voicesDropdown.AddOptions(voices.Select(elem => elem.Name).ToList());
            });

            voicesDropdown.onValueChanged.AddListener(value =>
            {
                SpeechEngine.SetVoice(voices[value]);
            });

            enginesDropdown.onValueChanged.AddListener(value =>
            {
                SpeechEngine.SetEngine(engines[value]);
            });
        });
    }
コード例 #5
0
        public void SpeechEngine_InstalledVoices()
        {
            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 0;

                SpeechEngine.Start(settings);

                foreach (var voice in SpeechEngine.InstalledVoices.Keys)
                {
                    PlayAudio(SpeechEngine.SpeakToFile(Phrase.PhoneVoiceText(voice, "Hello, my name is {0}.  I am one of the voices installed on your computer.", voice)));
                    Thread.Sleep(TimeSpan.FromSeconds(1.5));
                }
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #6
0
 public static void RegisterCommand(params Command[] ToRegister)
 {
     foreach (Command c in ToRegister)
     {
         Commands.Add(c);
         SpeechEngine.LoadGrammar(c.grammar);
     }
 }
コード例 #7
0
 public static void UnregisterCommand(params Command[] ToRegister)
 {
     foreach (Command c in ToRegister)
     {
         int Removed = Commands.RemoveAll(x => x.ID.ToString() == c.ID.ToString());
         SpeechEngine.UnloadGrammar(c.grammar);
     }
 }
コード例 #8
0
        public void PhraseCache_FanoutFolders_100()
        {
            // Verify that the cache creates the necessary folders for 100 fanout.

            string path;
            string fileName;
            int    pos;

            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 100;

                SpeechEngine.Start(settings);

                Assert.IsTrue(Directory.Exists(PhraseCachePath));
                Assert.IsTrue(Directory.Exists(OneTimePath));

                // Verify that the subfolders exist,

                for (int i = 0; i < 100; i++)
                {
                    Assert.IsTrue(Directory.Exists(Path.Combine(PhraseCachePath, string.Format("{0:0#}", i))));
                }

                // Verify that audio files are created in a subfolder.

                path     = SpeechEngine.PhraseCache.GetNextPhrasePath(Phrase.PhoneText("Hello World!"));
                fileName = Path.GetFileName(path);

                Assert.AreEqual(PhraseCachePath, path.Substring(0, path.Length - fileName.Length - 4));

                pos = PhraseCachePath.Length;   // Should index the "\" after the base cache path.

                Assert.AreEqual('\\', path[pos++]);
                Assert.IsTrue(Char.IsDigit(path[pos++]));
                Assert.IsTrue(Char.IsDigit(path[pos++]));
                Assert.AreEqual('\\', path[pos++]);

                // Verify that one-time files are created directly within the one-time folder.

                path     = SpeechEngine.PhraseCache.GetNextOneTimePath(Phrase.PhoneText("Hello World!"));
                fileName = Path.GetFileName(path);

                Assert.AreEqual(OneTimePath, path.Substring(0, path.Length - fileName.Length - 1));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #9
0
 /// <summary>
 /// Asks the next question if it's available
 /// </summary>
 public void StartNextQuestion()
 {
     if (FirebaseManager.Instance.HasQuestion())
     {
         _reader();
     }
     else
     {
         SpeechEngine.Speak("There's no question available.");
     }
 }
コード例 #10
0
 public void PlayInPlayerDownload(int voiceindex)
 {
     for (int i = 0; i < m_PlayerDownload.Count; i++)
     {
         if (m_PlayerDownload[i].VoiceIndex == voiceindex)
         {
             SpeechEngine.PlayAudio(m_PlayerDownload[i].VoiceIndex, m_PlayerDownload[i].VoiceBuffer, true);
             return;
         }
     }
 }
コード例 #11
0
        public void PhraseCache_FanoutFolders_0()
        {
            // Verify that the cache creates the necessary folders for 0 fanout.

            string path;
            string fileName;

            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 0;

                SpeechEngine.Start(settings);

                Assert.IsTrue(Directory.Exists(PhraseCachePath));
                Assert.IsTrue(Directory.Exists(OneTimePath));

                // Make sure there are no subfolders.

                Assert.IsFalse(Directory.Exists(Path.Combine(PhraseCachePath, "0")));
                Assert.IsFalse(Directory.Exists(Path.Combine(PhraseCachePath, "00")));
                Assert.IsFalse(Directory.Exists(Path.Combine(PhraseCachePath, "000")));
                Assert.IsFalse(Directory.Exists(Path.Combine(PhraseCachePath, "0000")));

                Assert.IsFalse(Directory.Exists(Path.Combine(PhraseCachePath, "1")));
                Assert.IsFalse(Directory.Exists(Path.Combine(PhraseCachePath, "01")));
                Assert.IsFalse(Directory.Exists(Path.Combine(PhraseCachePath, "001")));
                Assert.IsFalse(Directory.Exists(Path.Combine(PhraseCachePath, "0001")));

                // Verify that audio files are created directly in the cache folder.

                path     = SpeechEngine.PhraseCache.GetNextPhrasePath(Phrase.PhoneText("Hello World!"));
                fileName = Path.GetFileName(path);

                Assert.AreEqual(PhraseCachePath, path.Substring(0, path.Length - fileName.Length - 1));

                // Verify that one-time files are created directly within the one-time folder.

                path     = SpeechEngine.PhraseCache.GetNextOneTimePath(Phrase.PhoneText("Hello World!"));
                fileName = Path.GetFileName(path);

                Assert.AreEqual(OneTimePath, path.Substring(0, path.Length - fileName.Length - 1));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #12
0
 //CoRoutiune for displaying the text in the user input box located at the bottom of the screen. Provides visual cue on what the user has said.
 //Make sure the player text is cleared before writing  to text.
 //Split the text string input to the coroutine into a character array and iterate through the array, writing each character to screen.
 //When completed return out of the method.
 IEnumerator TypeUserInput(string input)
 {
     dialogueController.txtDialog.text = "";
     foreach (char letter in input.ToCharArray())
     {
         SpeechEngine.Speak(input);
         dialogueController.txtDialog.text += letter;
         yield return(null);
     }
     dialogueController.txtDialog.text = temporaryDialogueResponse;
 }
コード例 #13
0
 void Awake()
 {
     if (null != m_Instance)
     {
         Destroy(this.gameObject);
     }
     m_Instance = this;
     m_Status   = SpeechStatus.SS_DEFAULT;
     m_Instance.Init();
     DontDestroyOnLoad(this.gameObject);
 }
コード例 #14
0
        public void PhraseCache_CorruptIndex()
        {
            // Verify that the cache can start with a corrupt index file.

            Phrase phrase;

            DeleteFolder();

            Helper.CreateFileTree(PhraseCachePath);
            File.WriteAllBytes(Path.Combine(PhraseCachePath, PhraseCache.IndexFileName), new byte[] { 0 });

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 0;
                settings.DefaultVoice        = "Microsoft Anna";

                SpeechEngine.Start(settings);

                // Add a phrase to the cache with the [Microsoft Anna] voice.

                phrase      = Phrase.PhoneText("Hello World!");
                phrase.Path = SpeechEngine.PhraseCache.GetNextPhrasePath(phrase);
                File.WriteAllBytes(phrase.Path, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
                SpeechEngine.PhraseCache.AddPhrase(phrase);

                // Verify that the file is persisted in the SpeechEngine.PhraseCache.

                Assert.AreEqual(phrase.Path, SpeechEngine.PhraseCache.FindPhrase(phrase).Path);
                Assert.IsNotNull(SpeechEngine.PhraseCache.FindPhrase(Phrase.PhoneVoiceText("Microsoft Anna", "Hello World!")));

                // Verify that character case doesn't matter for voice names.

                Assert.IsNotNull(SpeechEngine.PhraseCache.FindPhrase(Phrase.PhoneVoiceText("MICROSOFT ANNA", "Hello World!")));

                // Verify that a search for a phrase with the same text but
                // a different voice does not return a cache hit.

                Assert.IsNull(SpeechEngine.PhraseCache.FindPhrase(Phrase.PhoneVoiceText("Microsoft Hayley", "Hello World!")));

                // Verify that a search for a phrase with the same voice but
                // different text does not return a cache hit.

                Assert.IsNull(SpeechEngine.PhraseCache.FindPhrase(Phrase.PhoneVoiceText("Microsoft Anna", "This is a test!")));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #15
0
        public bool Add(int voiceindex, byte[] voicebuffer)
        {
            if (voicebuffer == null)
            {
                return(false);
            }

            if (voicebuffer.Length <= 0)
            {
                return(false);
            }

            if (IsHaveVoice(voiceindex))
            {
                for (int i = 0; i < m_Record.Count; i++)
                {
                    if (m_Record[i].VoiceIndex == voiceindex)
                    {
                        m_Record.RemoveAt(i);
                        break;
                    }
                }
            }

            if (voiceindex == m_ForcePlayIndex)
            {
                if (m_PlayerDownload.Count >= m_PlayerDownloadMax)
                {
                    m_PlayerDownload.RemoveAt(0);
                }

                m_PlayerDownload.Add(new VoiceChat(voiceindex, voicebuffer));

                SpeechEngine.PlayAudio(voiceindex, voicebuffer, true);
            }
            else
            {
                if (m_Record.Count >= m_RecordMax)
                {
                    m_Record.RemoveAt(0);
                }

                m_Record.Add(new VoiceChat(voiceindex, voicebuffer));

                if (SpeechEngine.Status == SpeechEngine.SpeechStatus.SS_DEFAULT)
                {
                    PlayNextVoice();
                }
            }

            LogModule.DebugLog("PlayVoiceChat");

            return(true);
        }
コード例 #16
0
        public void PhraseCache_PurgeOrphaned()
        {
            // Verify that the cache deletes orhpaned files.

            string path1;
            string path2;

            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 10;
                settings.PhrasePurgeInterval = TimeSpan.FromSeconds(0.5);
                settings.MaxOneTimePhraseTTL = TimeSpan.FromSeconds(1);

                SpeechEngine.Start(settings);

                // Add couple files to the cache, one at the root and the second
                // in a subfolder.  Then force a cache purge and then verify that
                // the files were deleted and the index file still exists.

                path1 = Path.Combine(PhraseCachePath, "test1.dat");
                File.WriteAllText(path1, "test1");

                path2 = Path.Combine(PhraseCachePath, "0", "test2.dat");
                File.WriteAllText(path2, "test2");

                // Call the speech engine's background task handler so it
                // can handle cache purging and then verify that the
                // phrase was actually purged.

                Thread.Sleep(TimeSpan.FromSeconds(2));
                SpeechEngine.OnBkTask();
                Helper.WaitFor(() => !File.Exists(path1), TimeSpan.FromSeconds(5));

                Assert.IsFalse(File.Exists(path1));
                Assert.IsFalse(File.Exists(path2));

                // Make sure we didn't purge the index file by accident.

                Assert.IsTrue(File.Exists(Path.Combine(PhraseCachePath, PhraseCache.IndexFileName)));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #17
0
    //private List<SpeechUnit> m_AudioBuffers = new List<SpeechUnit>();

    // Use this for initialization
    void Start()
    {
        if (SpeechEngine.Instance() != null)
        {
            SpeechEngine.Instance().SetTextProcessHandler(ReceiveSpeechText);
            SpeechEngine.Instance().SetErrorProcessHandler(ReceiveErrorCode);
            SpeechEngine.Instance().SetRecordBeginHandler(DoRecordBegin);
            SpeechEngine.Instance().SetRecordEndHandler(DoRecordEnd);
            SpeechEngine.Instance().SetTaskCancleHandler(DoTaskCancle);
            SpeechEngine.Instance().SetTaskOverHandler(DoTaskOver);
            SpeechEngine.Instance().SetTaskStartHandler(DoTaskStart);
            SpeechEngine.Instance().SetAudioPlayOverHandler(PlayRecordOver);
        }
    }
コード例 #18
0
        public bool Add(int voiceindex, ByteString voicebuffer)
        {
            if (voicebuffer == null)
            {
                LogModule.DebugLog("voicebuffer == null");
                return(false);
            }

            if (voicebuffer.IsEmpty)
            {
                LogModule.DebugLog("voicebuffer.IsEmpty");
                return(false);
            }

            if (IsHaveVoice(voiceindex))
            {
                LogModule.DebugLog("IsHaveVoice(voiceindex)");
                return(false);
            }

            if (voiceindex == m_ForcePlayIndex)
            {
                if (m_PlayerDownload.Count >= m_PlayerDownloadMax)
                {
                    m_PlayerDownload.RemoveAt(0);
                }

                m_PlayerDownload.Add(new VoiceChat(voiceindex, voicebuffer.ToByteArray()));

                SpeechEngine.PlayAudio(voiceindex, voicebuffer.ToByteArray(), true);
            }
            else
            {
                if (m_Record.Count >= m_RecordMax)
                {
                    m_Record.RemoveAt(0);
                }

                m_Record.Add(new VoiceChat(voiceindex, voicebuffer.ToByteArray()));

                if (SpeechEngine.Status == SpeechEngine.SpeechStatus.SS_DEFAULT)
                {
                    PlayNextVoice();
                }
            }

            LogModule.DebugLog("PlayVoiceChat");

            return(true);
        }
コード例 #19
0
    /// <summary>
    /// 停止录音
    /// </summary>
    public static void StopRecording()
    {
        if (!m_bInited)
        {
            m_Instance.Init();
        }
        if (m_Status == SpeechStatus.SS_STARTED || m_Status == SpeechStatus.SS_READY || m_Status == SpeechStatus.SS_LISTENING)
        {
            SpeechAPI.StopRecording();
#if UNITY_ANDROID && !UNITY_EDITOR
            SpeechEngine.Instance().InvokeRepeating("StatusRecover", 11.0f, 1.0f);
#endif
        }
    }
コード例 #20
0
ファイル: _Handle.cs プロジェクト: leenabhandari/TourAR
    void Handle(string jsonString)
    {
        if (jsonString != null)
        {
            RootObject theAction = new RootObject();
            Newtonsoft.Json.JsonConvert.PopulateObject(jsonString, theAction);


            if (theAction.entities.section != null)
            {
                foreach (Section aPart in theAction.entities.section)
                {
                    Debug.Log(aPart.value);
                    //myHandleTextBox.text = aPart.value + "\nScan a marker near you";
                    text  = myHandleTextBox.text;
                    value = aPart.value;
                    //ArrowController.instance.triggerAnimation("moveRight");
                    if (value == "details")
                    {
                        myHandleTextBox.text = "The Taj Mahal , meaning Crown of the Palaces is an ivory-white marble mausoleum on the south bank of the Yamuna river in the Indian city of Agra. It was commissioned in 1632 by the Mughal emperor, Shah Jahan (reigned from 1628 to 1658), to house the tomb of his favourite wife, Mumtaz Mahal. It also houses the tomb of Shah Jahan, the builder. The tomb is the centerpiece of a 17-hectare (42-acre) complex, which includes a mosque and a guest house, and is set in formal gardens bounded on three sides by a crenellated wall. Do you want to know anything else?";
                        SpeechEngine.Speak(myHandleTextBox.text);
                    }
                    if (value == "time")
                    {
                        myHandleTextBox.text = "The grounds are open from 06:00 to 19:00 weekdays, except for Friday when the complex is open for prayers at the mosque between 12:00 and 14:00. The complex is open for night viewing on the day of the full moon and two days before and after, excluding Fridays and the month of Ramadan. Most tourists visit in the cooler months of October, November and February. Can I help you with anything else?";
                        SpeechEngine.Speak(myHandleTextBox.text);
                    }

                    if (value == "cost")
                    {
                        myHandleTextBox.text = "The fee for Indian citizens was 50 INR, for foreign tourists 1,100 INR. Is there anything else I can help you with?";
                        SpeechEngine.Speak(myHandleTextBox.text);
                    }
                    actionFound = true;
                }
            }


            if (!actionFound)
            {
                myHandleTextBox.text = "Request unknown, please ask a different way.";
                SpeechEngine.Speak(myHandleTextBox.text);
                text = myHandleTextBox.text;
            }
            else
            {
                actionFound = false;
            }
        } //END OF IF
    }     //END OF HANDLE VOID
コード例 #21
0
 public void ForcePlay(int voiceindex)
 {
     if (voiceindex == m_ForcePlayIndex)
     {
         for (int i = 0; i < m_Record.Count; i++)
         {
             if (m_Record[i].VoiceIndex == voiceindex)
             {
                 SpeechEngine.PlayAudio(m_Record[i].VoiceIndex, m_Record[i].VoiceBuffer, true);
                 return;
             }
         }
     }
 }
コード例 #22
0
    void Awake()
    {
        instance = this;
        locale   = Locale.WhithName(PlayerPrefs.GetString("SPEECH_ENGINE_LANGUAGE", Locale.ENGLISH.ToString()));

#if UNITY_EDITOR
        Debug.Log("Speech Engine cannot be used in editor mode please launch this app in android device !");
#elif UNITY_ANDROID
        Init();
#else
        Debug.LogWarningFormat("SpeechEngine is not enable in this platform ");
#endif

        DontDestroyOnLoad(gameObject);
    }
コード例 #23
0
    /// <summary>
    /// 开始录音
    /// </summary>
    public void StartSpeaking()
    {
        LogModule.DebugLog("StartSpeaking");

        GameManager.gameManager.SoundManager.MusicDown();

//         if (m_Input != null)
//         {
//             m_Input.value = "任务开始";
//         }

        m_Text    = "";
        m_IsError = false;
        SpeechEngine.StartRecording();
    }
コード例 #24
0
        public void PhraseCache_PurgeCache_WithSubfolders()
        {
            // Verify that the cache purges expired phrases within subfolders.

            Phrase phrase;

            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 10;
                settings.PhrasePurgeInterval = TimeSpan.FromSeconds(0.5);
                settings.MaxPhraseTTL        = TimeSpan.FromSeconds(1);

                SpeechEngine.Start(settings);

                // Create a phrase and add it to the cache.

                phrase      = Phrase.PhoneText("Hello World!");
                phrase.Path = SpeechEngine.PhraseCache.GetNextPhrasePath(phrase);
                File.WriteAllBytes(phrase.Path, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
                SpeechEngine.PhraseCache.AddPhrase(phrase);

                // Wait five seconds for the phrase to expire.

                Thread.Sleep(TimeSpan.FromSeconds(5));

                // Call the speech engine's background task handler so it
                // can handle cache purging and then verify that the
                // phrase was actually purged.

                SpeechEngine.OnBkTask();
                Helper.WaitFor(() => !File.Exists(phrase.Path), TimeSpan.FromSeconds(5));

                Assert.IsNull(SpeechEngine.PhraseCache.FindPhrase(phrase));
                Assert.IsFalse(File.Exists(phrase.Path));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #25
0
        public static void InitialiseSpeech()
        {
            if (Commands.Count > 0)
            {
                foreach (var C in Commands)
                {
                    if (SpeechEngine.Grammars.Contains(C.grammar))
                    {
                        continue;
                    }
                    SpeechEngine.LoadGrammar(C.grammar);
                }

                SpeechEngine.SetInputToDefaultAudioDevice();

                SpeechEngine.RecognizeAsync(RecognizeMode.Multiple);
            }
        }
コード例 #26
0
    /// <summary>
    /// 任务结束回调
    /// </summary>
    private void DoTaskOver()
    {
        LogModule.DebugLog("DoTaskOver");
        if (!m_IsError && !String.IsNullOrEmpty(m_Text))
        {
            byte[] buffer = SpeechEngine.GetAudioBuffer();
            if (ChatInfoLogic.Instance())
            {
                ChatInfoLogic.Instance().OnSpeechTaskOver(m_Text, buffer);
            }
            if (ChatFrameLogic.Instance())
            {
                ChatFrameLogic.Instance().OnSpeechTaskOver(m_Text, buffer);
            }
            m_Text = "";
        }

        m_IsError = false;
    }
コード例 #27
0
    /// <summary>
    /// Assign the right mode for the interview
    /// </summary>
    /// <param name="op">Whether the question should be asked by the audience or not.</param>
    public void AssignReader(bool op)
    {
        SpeechEngine.SetLanguage(Locale.English);

        if (op)
        {
            _reader += VoiceReader;

            SpeechEngine.SetVoice(SpeechEngine.AvaillableVoices.First(voice => voice.Name.Equals("en-gb-x-rjs-network")));
        }
        else
        {
            _reader += AudienceReader;
            TheaterManager.Instance.ActivateColliders();
        }

        questionCanvas.SetActive(false);
        interviewCanvas.SetActive(true);
    }
コード例 #28
0
        public void SpeechEngine_DefaultVoice()
        {
            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 0;

                SpeechEngine.Start(settings);

                PlayAudio(SpeechEngine.SpeakToFile(Phrase.PhoneText("Hello, I am {0}.  I am the default system voice.", SpeechEngine.DefaultVoice)));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #29
0
        public void SpeechEngine_BadVoice()
        {
            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 0;

                SpeechEngine.Start(settings);

                PlayAudio(SpeechEngine.SpeakToFile(Phrase.PhoneVoiceText("Bad Voice", "An invalid voice was specified.  The default voice is being used instead.")));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }
コード例 #30
0
        public void SpeechEngine_MicrosoftAnna()
        {
            //Assert.Ignore("[Microsofy Anna] is not working for some reason.");

            DeleteFolder();

            try
            {
                var settings = new SpeechEngineSettings();

                settings.PhraseCacheFolder   = PhraseCachePath;
                settings.OneTimePhraseFolder = OneTimePath;
                settings.PhraseFolderFanout  = 0;

                SpeechEngine.Start(settings);

                PlayAudio(SpeechEngine.SpeakToFile(Phrase.PhoneVoiceText("Microsoft Anna", "Hello, I am Microsoft Anna.  I am installed on all Windows operating systems.")));
            }
            finally
            {
                SpeechEngine.Stop();
                DeleteFolder();
            }
        }