I've done this using MSs speech API in C#. When I get a minute I'll post some source code.
I would like to be able to talk to people in the room using that.. anyone come up with anything like that?
I would imagine it would just invovle some .exe that would run the txt2speech API and create a wave and then somehow send it to the rovio ?
From the API:
Other - GetAudio.cgi
Description
Send audio to server and playback at server side
Grammar
/GetAudio.cgi
The data flow is from client to IPCam, which is different from GetData.cgi.
The audio data must be send with HTTP POST method.
Audio format: 16bit PCM, 8000Hz
Should be able to do this with this information. Looks like the last poster has figured it out. I look forward to his C# code. I'm going to have to do this too. (Rovio yelling "Help Me!" if it gets stuck?)
This works. The audio is very soft so it needs to be boosted, but maybe one of you guys can figure that out and repost a better example.
private void Say(string text)
{
try
{
_rovioAudioSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
System.Net.IPEndPoint remoteEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(_rovioIPAddress), _rovioAudioPort);
_rovioAudioSocket.Connect(remoteEndPoint);
textBox1.AppendText(DateTime.Now.ToString() + " : Audio socket connected\r\n");
// Prepare the audio port for sending audio from the PC back to the Rovio
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);
//REVIEW: skipping Credentials
if (_rovioAudioSocket.Send(szSend) == -1)
{
textBox1.AppendText(DateTime.Now.ToString() + " : Error sending initial packet\r\n");
}
Stream stream = new MemoryStream();
byte[] format = new byte[0];
speaker.SetOutputToAudioStream(stream, new SpeechAudioFormatInfo(8000, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
speaker.Volume = 100;
speaker.Rate = -8;
speaker.Speak(text);
stream.Seek(0, SeekOrigin.Begin);
byte[] output = new byte[stream.Length];
stream.Read(output, 0, (int)stream.Length);
_rovioAudioSocket.Send(output);
_rovioAudioSocket.Close();
textBox1.AppendText(DateTime.Now.ToString() + " : Audio socket closed\r\n");
}
catch (Exception ex)
{
textBox1.AppendText(DateTime.Now + " :: " + ex.Message.ToString() + "\r\n");
}
}
View unverified member's comment - posted by The Cpp
This is just the port you have assigned for communicating with the Rovio (80 by default).
I would greatly appreciate if someone gave an example of using GetAudio.cgi in python.
boltun said:
I would greatly appreciate if someone gave an example of using GetAudio.cgi in python.
Answering my own question:
def say(text):
output = subprocess.Popen('echo "'+text+'" | text2wave -f 8000 -o test.wav',shell=True).communicate()[0]
#Could not find a way to send a file with urllib2
c = Curl()
c.setopt(c.POST, 1)
c.setopt(c.URL, 'http://'+username+':'+password+'@'+url+'/GetAudio.cgi')
c.setopt(c.HTTPPOST, [("file", (c.FORM_FILE, "test.wav"))])
try:
c.perform()
except:
pass
c.close()
RSS

