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[] { }); }
public void Say(string message) { var packet = new SpeechRequest { Type = SpeechType.Normal, Text = message, Font = 0x02b2, Color = 0x0003, Language = "ENU" }; Send(packet.RawPacket); }
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); }
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, }); }
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"); }
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); }
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"); }
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); }