<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.5764" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi Artem,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Please to see that some of the stuff I wrote is
useful to someone..!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I've written an FS module which will send the
audio over - it's more efficient than using unicast. Let me know if you'd
like a copy.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Cheers --</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Dave</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=ryder86@googlemail.com href="mailto:ryder86@googlemail.com">Артем
Васильев</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=freeswitch-users@lists.freeswitch.org
href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, May 26, 2009 9:27 AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Freeswitch-users] Unicast isn't
working</DIV>
<DIV><BR></DIV>Hi,<BR><BR>I am trying to setup ASR in FreeSwitch using Nuance
ASR server and MRCP. Both FreeSwitch and Nuance installed on Windows Server
2003. FreeSwitch version is 1.0.3 (12567M)<BR><BR>I found an example in Perl
at <A
href="http://www.softivr.com/wiki/index.php/FreeSWITCH_MRCP_in_Perl">http://www.softivr.com/wiki/index.php/FreeSWITCH_MRCP_in_Perl</A>
and decided to do the same in C#.<BR>It establishes connection with Nuance and
loads the grammar, everything works fine. The next step is to capture audio
from FS and tramsmit it to ASR. This can be done with unicast. We must create
an outbound socket and issue "unicast" command. Here it goes:<BR><BR>private
void SetupAudioTransmission()<BR>{<BR> EventSocket = new
Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);<BR> EventSocket.SendTimeout =
Config.Timeout;<BR> int ESPort =
SearchESPort(EventSocket);<BR><BR> Thread thrESListener = new Thread(new
ThreadStart(ListenerThreadStart));<BR> thrESListener.Start();<BR> <BR> WriteLog(LogLevel.Info,
"Creating outbound event socket");<BR> Session.Execute("socket", "<A
href="http://127.0.0.1">127.0.0.1</A>:" + ESPort); //main thread stops,
listener thread listens for outbound socket
connection.<BR> WriteLog(LogLevel.Info, "Outbound event socket
disconnected");<BR><BR> EventSocket.Close();<BR>}<BR> <BR>//here
we accept outbound socket and transmit unicast command through it<BR>private
void ListenerThreadStart()<BR>{<BR> Socket sockHandler =
EventSocket.Accept();<BR> WriteLog(LogLevel.Info, "Incoming
connection");<BR> sockHandler.Send(MessageEncoding.GetBytes("Connect\n\n"));<BR>
<BR> WriteLog(LogLevel.Info,
GetServerResponse(sockHandler));<BR><BR> int rtpPort =
(RTPSocket.RemoteEndPoint as IPEndPoint).Port;<BR> string command =
string.Format("sendmsg\r\ncall-command: unicast\r\nlocal-ip:
{0}\r\nlocal-port: {1}\r\nremote-ip: {2}\r\n" +<BR> "remote-port:
{3}\r\ntransport: udp\r\nflags: native\r\n\r\n", Config.LocalIP, rtpPort + 1,
Config.LocalIP, rtpPort);<BR><BR> WriteLog(LogLevel.Info,
command);<BR><BR> sockHandler.Send(MessageEncoding.GetBytes(command));<BR> WriteLog(LogLevel.Info,
GetServerResponse(sockHandler));<BR> <BR> sockHandler.Disconnect(false);
<BR> sockHandler.Close(); <BR>}<BR><BR>After this, FS writes
that unicast has been created on corresponding IPs and ports. It really
creates an UDP socket, but doesn't transmit any data through it. I tested it
with Wireshark and from my application, nothing was detected.<BR>Also, if we
specify "transport:tcp" in unicast command, it uses UDP anyway, that's
strange.<BR><BR>Here is how I listen UDP packets.<BR>private void
DetectSpeech()<BR>{<BR> WriteLog(LogLevel.Info, "Reading
audio");<BR> byte[] FSRecvBuf = new
byte[2048];<BR> <BR> IPEndPoint epFS = new
IPEndPoint(IPAddress.Loopback, (RTPSocket.RemoteEndPoint as
IPEndPoint).Port);<BR> FSSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);<BR> FSSocket.ReceiveTimeout =
100000;<BR> FSSocket.SendTimeout =
100000;<BR> WriteLog(LogLevel.Info, "Binding socket to " +
epFS.Port);<BR><BR> FSSocket.Bind(epFS);<BR> FSSocket.Connect(new
IPEndPoint(IPAddress.Loopback, epFS.Port + 1));<BR>
<BR> while (Session.Ready())<BR> {<BR> int recvCount =
FSSocket.Receive(FSRecvBuf);<BR> WriteLog(LogLevel.Info, "Received
bytes: " + recvCount);<BR> }<BR>}<BR><BR>Can someone help me to solve
this? Do I do something wrong or I forgot something or it doesn't work at
all?<BR><BR>Best regards.<BR>Artem<BR><BR>
<P>
<HR>
<P></P>_______________________________________________<BR>Freeswitch-users
mailing
list<BR>Freeswitch-users@lists.freeswitch.org<BR>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<BR>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<BR>http://www.freeswitch.org<BR></BLOCKQUOTE></BODY></HTML>