Voice recording in a website

Guys can any one tell me some way through which i will be able to record my voice via web browser and upload it to web server

Replies

  • Ankita Katdare
    Ankita Katdare
    Hi Goyal,

    I found this article:
    #-Link-Snipped-#

    Contents of that article:

    This isn't so tough, but my concern with the wording of this question is that the user thinks that perhaps it's possible to record the microphone client side and then save it on the server.
    If by chance that is the case, then it isn't really possible. The best you can do in that area with just flash is to buffer a lot and then have the flash player "upload" it to the server. But in reality, it's not saving it anywhere in hard memory and is deleted if you close the flash player. The reason you might want to do something like this is if you are concerned that the user's bandwidth is much lower than they may need to stream the audio up to the server. So you buffer it on the client side (usually if it's under 30 seconds of audio you should be ok) and then flush the buffer when it reaches the limit.
    So, how about some code then:
    I won't cover making a net connection to the server and all that because I've talked about that in the past and there really are lots of examples of it (every FMS app needs to connect to the server..)
    Once a connection has been made to the server, let's call a function called getMic()
    Assuming the netConnection object is "nc", netstream to publish the mic is "ns" and the microphone object is "mic"
    //this function will get the microphone object and set some parameters for it
    function getMic(){
    //first we need a netstream object to connect the mic to
    ns = new NetStream(nc);
    //set a small buffer
    ns.setBufferTime(2);
    //we need the microphone object now, get the default mic by passing in nothing in the parantheses
    mic = Microphone.get();
    //set the quality of the microphone, this can be set to 5, 8, 11, 22, or 44
    mic.setRate(22);
    //attach the microphone object to the netstream
    ns.attachAudio(mic);
    //and publish it to the server by passing in the file name and record command. If you want a live stream, then just pass in "LIVE" instead of "RECORD"
    ns.publish("myMicrophone", "RECORD");
    }
    and that's it really. There are a few other options for the microphone which can be seen #-Link-Snipped-#.
  • Morningdot Hablu
    Morningdot Hablu
    How if you use java to do this.
    I am currently working on voice recording using java.It's not too hard to do.
    In which format you want to save it(mp3 or wav) ?
  • Manish Goyal
    Manish Goyal
    any format buddy
    Do you have any java applet through which users voice recording is possible ?

    Please give me the code if possible
  • Morningdot Hablu
    Morningdot Hablu
    I will try to do this in consol but i got an file format not supported exception check this.
    .
    java.lang.IllegalArgumentException: could not write audio file: file type not supported: null
    at javax.sound.sampled.AudioSystem.write(AudioSystem.java:1363)
    at pp.run(pp.java:30)
    The codes are like this
    import java.io.*;
    import javax.sound.sampled.*;
    public class pp extends Thread
    {
    TargetDataLine tdl;
    AudioFileFormat.Type afft;
    AudioInputStream ais;
    File f1;
    public pp(TargetDataLine l,AudioFileFormat.Type t,File f2)
    {
    tdl=l;
    ais=new AudioInputStream(tdl);
    afft=t;
    f1=f2;
    }
    public void start()
    {
    tdl.start();
    super.start();
    }
    public void sr()
    {
    tdl.stop();
    tdl.close();
    }
    public void run()
    {
    try
    {
    AudioSystem.write(ais,afft,f1);
    }
    catch(Exception e)
    {
    e.printStackTrace();
    System.out.println("Exception caught ");
    }
    }
    public static void main(String args[])
    {
    String s=args[0];
    File f=new File(s);
    AudioFormat ff=new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,44100.0F, 16, 2, 4, 44100.0F, false);
    DataLine.Info inf=new DataLine.Info(TargetDataLine.class,ff);
    TargetDataLine td=null;
    try
    {
    td=(TargetDataLine)AudioSystem.getLine(inf);
    td.open(ff);
    }
    catch(Exception e)
    {
    //e.printStackTrace();
    System.out.println("Exception caught ");
    }
    AudioFileFormat.Type t5=AudioFileFormat.Type.AIFC;
    pp p=new pp(td,t5,f);
    System.out.println("enter to start recording");
    try
    {
    System.in.read();
    }
    catch(Exception e)
    {
    System.out.println("exception caught ");
    }
    p.start();
    System.out.println("enter to stop recording");
    try
    {
    System.in.read();
    }
    catch(Exception e)
    {
    System.out.println("exception caught ");
    }
    p.sr();
    System.out.println("recording stoped");
    }
    }
    Once you done with consol its easy to implement in Applet or in your own created frame.
    You can create the event on JSlider.
    Hope it will help you.I will try to fix this exception.Once i done i will make an applet page for you.
  • bhargava.megha
    bhargava.megha
    @ above
    i m working on project which is some like yahoo messenger (MULTI USER CHAT WITH VOICE & VIDEO ) BASED ON JAVA CAN U PLAESE HELP ME IN multi chat & also in voice and video implementation
    PLEASE ITS VERY URGENT AND IMPORTANT
  • Morningdot Hablu
    Morningdot Hablu
    @bhargava I don't think you have to record the voice for that.You have to take the input from user and put your output streams on the network for the other user to take the input from them.You need socket programming for that.
    I didn't handled any project till now but i think this is the main theme on which you have to work on.
    .
    May i know up to what you have done...?
  • Morningdot Hablu
    Morningdot Hablu
    Lets divide your project into threes parts.
    1.>designing of applet.
    2.>communication between applets.
    3.>do the socket programming for that.
    Just start your project with the first one.It's not hard to do.Post your quarries if you found any problem.
  • bhargava.megha
    bhargava.megha
    @mohit
    thanx
  • bhargava.megha
    bhargava.megha
    @ mohit
    but i have to add voice & video feature in that
    like YAHOO MESSENGER but i dont know how it will implement
    please i dont find any exact help from net..
    if u can do any thing then pls try
  • Morningdot Hablu
    Morningdot Hablu
    Check these two programs.
    for client....
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.*;
    import java.awt.event.*;
    /**/
    public class sas extends JApplet implements ActionListener
    {
    JTextArea t;
    JButton b;
    public void init()
    {
    t=new JTextArea(10,20);
    b=new JButton("open");
    setLayout(new FlowLayout());
    add(t);
    b.addActionListener(this);
    add(b);
    }
    public void actionPerformed(ActionEvent e)
    {
    byte b[]=new byte[60];
    try
    {
    Socket s=new Socket("127.0.0.1",4444);
    InputStream bis=s.getInputStream();
    BufferedInputStream bi=new BufferedInputStream(bis);
    bis.read(b);
    String str=new String(b);
    t.setText(str);
    }
    catch(Exception ee)
    {
    ee.printStackTrace();
    System.out.println("exception caught ");
    }
    }
    }
    for client....
    .
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.*;
    import java.applet.*;
    import java.awt.event.*;
    /**/
    public class xx extends JApplet implements ActionListener
    {
    JTextArea t;
    JButton b;
    public void init()
    {
    t=new JTextArea(10,20);
    b=new JButton("submit");
    setLayout(new FlowLayout());
    add(t);
    b.addActionListener(this);
    add(b);
    }
    public void actionPerformed(ActionEvent e)
    {
    byte b[]=new byte[60];
    String str;
    byte b1[]=new byte[60];
    try
    {
    ServerSocket s=new ServerSocket(4444);
    Socket s1=s.accept();
    str=t.getText();
    b1=str.getBytes();
    ByteArrayInputStream bai=new ByteArrayInputStream(b1);
    BufferedInputStream bis=new BufferedInputStream(bai);
    bis.read(b);
    OutputStream os=s1.getOutputStream();
    os.write(b);
    //System.out.println(t.getText());
    }
    catch(Exception ee)
    {
    System.out.println("Exception caught ");
    }
    }
    }
    .
    try to execute this it may give you some idea.
  • Morningdot Hablu
    Morningdot Hablu
    As i said previously You have to take the input from user and put your output streams on the network for the other user to take the input from them.You need socket programming for that.
    you may take the help of JMF.It will provide some additional packages for you.

You are reading an archived discussion.

Related Posts

When 14-year-old Suhas Gopinath started Globals Inc ten years ago from a cyber cafe in Bengaluru, he didn't know that he had become the youngest CEO in the world. ​...
One day, the roboticists at Willow Garage were thirsty, so they decided to teach their quick-learning PR2 robot a few tricks. PR2 already knew how to fold laundry and play...
YDreams" largest project to date, "El Faro" Visitors Center, is the gateway to Santander Group's financial complex on the outskirts of Madrid. The center is a creative mix of advanced...
You are about to see, some really crazy mind-blowing stuff here. :shock: The Nao Robot by Aldebaran Robotics is an amazingly advanced bot that boasts cognitive skills, a high level...