예제 #1
0
파일: SystemInfo.cs 프로젝트: ext0/Phoenix
        public static byte[] speakText(Command command)
        {
            SpeechRequest     request = (SpeechRequest)Util.Serialization.deserialize(command.data);
            SpeechSynthesizer synth   = new SpeechSynthesizer();

            synth.SelectVoice(request.name);
            synth.Volume = request.volume;
            synth.SpeakAsync(request.text);
            return(new byte[] { });
        }
예제 #2
0
        public void Say(string message)
        {
            var packet = new SpeechRequest
            {
                Type     = SpeechType.Normal,
                Text     = message,
                Font     = 0x02b2,
                Color    = 0x0003,
                Language = "ENU"
            };

            Send(packet.RawPacket);
        }
예제 #3
0
        public void Say(string message, ushort[] keywords, SpeechType type, Color color, ushort font, string language)
        {
            var packet = new SpeechRequest
            {
                Type     = type,
                Text     = message,
                Font     = font,
                Color    = color,
                Language = language,
                Keywords = keywords
            };

            Send(packet.RawPacket);
        }
예제 #4
0
 public static Speech ToSpeech(this SpeechRequest src)
 {
     return(new Speech()
     {
         Id = Guid.NewGuid(),
         CityId = src.CityId,
         Location = src.Location,
         Description = src.SpeechDescription,
         StartTime = src.StartTime,
         EndTime = src.EndTime,
         IsActive = true,
         SpeakerId = src.SpeakerId,
         Name = src.SpeechName,
     });
 }
예제 #5
0
        public void Can_deserialize_unicode()
        {
            var rawPacket = FakePackets.Instantiate(new byte[]
            {
                0xAD,                                                       // packet
                0x00, 0x16,                                                 // size
                0x00,                                                       // type
                0x02, 0xB2,                                                 // color
                0x00, 0x03,                                                 // font
                0x45, 0x4E, 0x55, 0x00,                                     // language
                0x00, 0x61, 0x00, 0x73, 0x00, 0x64, 0x00, 0x66, 0x00, 0x00, // message
            });

            var packet = new SpeechRequest();

            packet.Deserialize(rawPacket);

            packet.Text.Should().Be("asdf");
        }
예제 #6
0
        public HttpResponseMessage Speak([FromBody] SpeechRequest request)
        {
            Program.ReportActivity();
            var sw = Stopwatch.StartNew();

            Console.Title = "Busy";
            try
            {
                byte[] responseBytes = null;
                if (!string.IsNullOrEmpty(request.Ssml))
                {
                    //new PromptBuilder().StartStyle(new PromptStyle()
                    responseBytes = Speech.Speech.SpeakSsml(request.Ssml, request.VoiceName);
                }

                if (!string.IsNullOrEmpty(request.Text))
                {
                    responseBytes = Speech.Speech.SpeakText(request.Text, request.VoiceName);
                }

                var response = new HttpResponseMessage()
                {
                    Content = new ByteArrayContent(responseBytes)
                };
                return(response);
            }
#pragma warning disable 168
            catch (Exception ex)
#pragma warning restore 168
            {
                Console.WriteLine(ex);

                // ignored
            }
            finally
            {
                Console.Title = "On hold";
                Console.WriteLine($"{DateTime.UtcNow.ToShortTimeString()}: Handling Speak took '{sw.Elapsed}'");
            }

            return(null);
        }
예제 #7
0
        public void Can_deserialize_packet_with_keywords()
        {
            var rawPacket = FakePackets.Instantiate(new byte[]
            {
                0xAD,                               // packet
                0x00, 0x15,                         // size
                0xC0,                               // type
                0x02, 0xB2,                         // color
                0x00, 0x03,                         // font
                0x45, 0x4E, 0x55, 0x00,             // language
                0x00, 0x10, 0x1C,                   // keywords
                0x2C, 0x74, 0x65, 0x73, 0x74, 0x00, // message
            });

            var packet = new SpeechRequest();

            packet.Deserialize(rawPacket);

            packet.Text.Should().Be(",test");
        }
예제 #8
0
        public byte[] Speak(SpeechRequest request)
        {
            Program.ReportActivity();
            var sw = Stopwatch.StartNew();

            Console.Title = "Busy";
            try
            {
                byte[] responseBytes = null;
                if (!string.IsNullOrEmpty(request.Ssml))
                {
                    //new PromptBuilder().StartStyle(new PromptStyle()
                    responseBytes = Speech.Speech.SpeakSsml(request.Ssml, request.VoiceName);
                }

                if (!string.IsNullOrEmpty(request.Text))
                {
                    responseBytes = Speech.Speech.SpeakText(request.Text, request.VoiceName);
                }

                return(responseBytes);
            }
#pragma warning disable 168
            catch (Exception ex)
#pragma warning restore 168
            {
                Console.WriteLine("Error while reading:\n" + (request.Ssml ?? request.Text) + "\n\n\n" + ex);

                // ignored
            }
            finally
            {
                Console.Title = "On hold";
                Console.WriteLine($"{DateTime.UtcNow.ToShortTimeString()}: Handling Speak took '{sw.Elapsed}'");
            }

            return(null);
        }