 |
Exercise 22 Solution
using System; using System.Net; using System.Net.Sockets; using System.Text;
namespace Grace { /// <summary> /// Class to connect to Expressivo and speak some text. /// </summary> public class ExpressivoVoice { public static void Speak(string text) { Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
System.Net.IPAddress ip = System.Net.IPAddress.Parse("127.0.0.1"); System.Net.IPEndPoint endPoint = new IPEndPoint(ip, 17024);
byte[] byteArray = ASCIIEncoding.UTF8.GetBytes("SayIt|" + text + "\r\n");
s.Connect(endPoint);
s.Send(byteArray); } } }
|
|
|
|
 |