Ejemplo n.º 1
0
        public void Phrase_EncodeDecode()
        {
            // Verify that phrases can be encoded and decoded into string form.

            Phrase phrase1;
            Phrase phrase2;
            string encoded;

            phrase1 = Phrase.PhoneVoiceText("Microsoft Anna", "This is a test.");
            encoded = phrase1.Encode();
            phrase2 = Phrase.Decode(encoded);

            Assert.AreEqual(PhraseType.Text, phrase2.PhraseType);
            Assert.AreEqual(false, phrase2.IsOneTime);
            Assert.AreEqual(TtsSampleRate.KHz_8000, phrase2.SampleRate);
            Assert.AreEqual(TtsEncoding.Pcm8, phrase2.Encoding);
            Assert.AreEqual("Microsoft Anna", phrase2.Voice);
            Assert.AreEqual("This is a test.", phrase2.Text);

            phrase1           = Phrase.PhoneVoiceSsml("Microsoft Haley", "Hello World!");
            phrase1.IsOneTime = true;
            encoded           = phrase1.Encode();
            phrase2           = Phrase.Decode(encoded);

            Assert.AreEqual(PhraseType.Ssml, phrase2.PhraseType);
            Assert.AreEqual(true, phrase2.IsOneTime);
            Assert.AreEqual(TtsSampleRate.KHz_8000, phrase2.SampleRate);
            Assert.AreEqual(TtsEncoding.Pcm8, phrase2.Encoding);
            Assert.AreEqual("Microsoft Haley", phrase2.Voice);
            Assert.AreEqual("Hello World!", phrase2.Text);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called by NeonSwitch to execute a synchronous subcommand.
        /// </summary>
        /// <param name="args">The command execution context including the arguments.</param>
        /// <remarks>
        /// <note>
        /// Implementations can use the various <see cref="ExecuteEventArgs.Write(string)"/> method
        /// overloads in <see cref="ExecuteEventArgs"/> to stream text back to the caller.
        /// </note>
        /// </remarks>
        public void Execute(ExecuteEventArgs args)
        {
            try
            {
                var phrase = Phrase.Decode(args.SubcommandArgs);

                args.Write(SpeechEngine.SpeakToFile(phrase));
            }
            catch (Exception e)
            {
                SysLog.LogException(e);

                args.Write(SpeechEngine.ErrorAudioPath);
            }
        }