OUR NETWORK:TechLore Sling Community MyOpenRouter MediaSmart home Pogoplugged See all... About UsAdvertiseContact Us

 
Learn about scoring Forum's Raw Score: 114396.0
November 8, 2009 10:32 AM

Categories: Rovio Development

Rating (0 votes)
Rate This!

Member Avatar

Paranosh

  Member
Joined: 02/09/2009

 Works, but i think cos there.s a problem with the length, somebody can fix it?

private void Say(string texto)

{

byte[] szSend;

string _rovioIPAddress = "{ROVIOIP:PORT}";

Uri URL = new Uri(http://{ROVIOIP:PORT}/GetAudio.cgi);

HttpWebRequest request = WebRequest.Create("http://{ROVIOIP:PORT}/GetAudio.cgi") as HttpWebRequest;request.Method = "POST";

request.ContentType = "application/x-www-form-urlencoded";

NetworkCredential myCred = new NetworkCredential("USER", "PASSWORD");

CredentialCache MyCrendentialCache = new CredentialCache();MyCrendentialCache.Add(URL,"Basic", myCred);

request.Credentials = MyCrendentialCache;

string temp = "POST /GetAudio.cgi HTTP/1.1\r\n" + "User-Agent: AudioAgent\r\n" + "Host: " + _rovioIPAddress + "\r\n" + "Content-Length: 2147483647\r\n" + "Cache-Control: no-cache\r\n" + "\r\n";

szSend = StringToByteArray(temp);

Stream stream = new MemoryStream();

SpeechSynthesizer speaker = new SpeechSynthesizer();

byte[] format = new byte[0];speaker.SetOutputToAudioStream(stream, new SpeechAudioFormatInfo(8000, AudioBitsPerSample.Sixteen, AudioChannel.Mono));

speaker.Volume = 100;

speaker.Rate = -2;

speaker.Speak(texto);

stream.Seek(0,
SeekOrigin.Begin);

byte[] output = new byte[stream.Length];stream.Read(output, 0, (int)stream.Length);

using (Stream dataStream = request.GetRequestStream())

{

dataStream.Write(output, 0, (
int)stream.Length);

}

HttpWebResponse response;

StreamReader reader;

try

{

using (response = request.GetResponse() as HttpWebResponse)

{

reader =
new StreamReader(response.GetResponseStream());

reader.ReadToEnd();

}

}

catch (WebException webEx)

{

}

catch (Exception ex)

{

}

finally

{

if (request != null) request.GetRequestStream().Close();

}

}

Discussion:    Add a Comment | Comments 1-3 of 3 | Latest Comment

November 8, 2009 3:57 PM

I forget some code:

private static byte[] StringToByteArray(string inputString)
{
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
return encoding.GetBytes(inputString);
}

January 30, 2010 7:02 PM

Myabe I will try to add to lib

January 31, 2010 2:35 AM

Feel free to manage the code as you like it, check codeplex i posted two functions more in discusions.
Ps.- the library has a bug (sintax like), on the movement control, check it please.
Regards.

Discussion:    Add a Comment | Comments 1-3 of 3 | Latest Comment

Add Your Reply

(will not be displayed)

Email me when comments are added to this thread

 
 

Please log in or register to participate in this community!

Log In

Remember

Not a member? Sign up!

Did you forget your password?

You can also log in using OpenID.

close this window
close this window