I have done research and read forums where listening to the DTMF port has been discussed where skype sends its audio for paplications to listen and use. Its source code is with attachmend and at the end of this post also.
This code listens the audio from the port and writes it to the wav file. Now I need some innovative idea so that I can supply that data LIVE to some other device like sound card or modem or anything else rather storing it in wav file.
I need to do this because I need that audio as input to me speech application to process it, which normally takes input from MIC.
Any innovative thougts.
====================================================================
CODE
#define J_SHARP//To compile with J#
package ConsoleApplication1;
/**
* Summary description for Program
*/
import java.io.*;
import java.net.*;
public class Listen2SkypeCall
{
public static void main(String[] args)
{
// declaration section:
// declare a server socket and a client socket for the server
// declare an input stream
ServerSocket SkypeServer = null;
DataInputStream is;
Socket clientSocket = null;
//Buffer for all received data
byte[] buffer = new byte[8192*1024];//8M should be enough for short test calls
byte[] WavHeader ={
'R','I','F','F','?','?','?','?',
'W','A','V','E','f','m','t',32,
16,0,0,0,1,0,1,0,
(byte)128,62,0,0,0,125,0,0,
2,0,16,0,'d','a','t','a',
'?','?','?','?'
};
// Try to open a server socket on port 4444
// Note that we can't choose a port less than 1023 if we are not
// privileged users (root)
try
{
SkypeServer = new ServerSocket(4444);
}
catch (IOException e)
{
System.out.println(e);
}
//Copy .wav header template to buffer:
int end = 44;
for (int i = 0; i < end; i++)
buffer[i] = WavHeader[i];
// Create a socket object from the ServerSocket to listen and accept
// connections.
try
{
// Open input stream
clientSocket = SkypeServer.accept();
is = new DataInputStream(clientSocket.getInputStream());
// As long as we receive data, write them to buffer.
while (true)
{
#if !J_SHARP
int length = clientSocket.getReceiveBufferSize();//J# does not understand it
#else
int length = 8192;
#endif
int chunksize = is.read(buffer, end, length);
if (chunksize == -1) break;//End of transmission
end += chunksize;
}
}
catch (IOException e)
{
System.out.println(e);
}
//Now we can correct the .wav header:
int2bytes(buffer, 4, end - 8);
int2bytes(buffer, 40, end - 44);
//and to write the buffer to an output file:
try
{
FileOutputStream out = new FileOutputStream("C:\\myfile.wav");
out.write(buffer, 0, end);
out.close();
}
catch (Exception e)
{
// TODO: handle exception
}
}
public static void int2bytes(byte[] buffer, int where, int N)
{
for (int i = 0; i < 4; i++)
{
buffer[where + i] = (byte)(N % 256);
N /= 256;
}
}
}