我在坛子里搜索了,没有找到合适的,还请各位朋友们帮帮忙。
我要实现的目的是通过麦克接收用户语音指令,执行相应指令。
对于语速,方言等最好有比较好的兼容性。
谢谢。
分不是问题,问题也不是没分,所以,帮帮忙吧,哥们有的是分。谢谢

解决方案 »

  1.   

    楼主试试这个!希望对你有帮助...package CSDN;import java.io.*;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.SourceDataLine;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.FloatControl;
    import javax.sound.sampled.TargetDataLine;
    public class RecordAndPlay {
        volatile int divider;
        public RecordAndPlay(){
            Play();
        }
        public static void main(String[] args) {
            new RecordAndPlay();
        }
        //播放音频文件
        public void Play() {        try {
                AudioFormat audioFormat =
    //                    new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100F,
    //                    8, 1, 1, 44100F, false);
                 new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,44100F, 16, 2, 4,
                 44100F, true);
                DataLine.Info info = new DataLine.Info(TargetDataLine.class,
                        audioFormat);
                TargetDataLine targetDataLine = (TargetDataLine) AudioSystem.getLine(info);
                targetDataLine.open(audioFormat);
                SourceDataLine sourceDataLine;
                info = new DataLine.Info(SourceDataLine.class, audioFormat);
                sourceDataLine = (SourceDataLine) AudioSystem.getLine(info);
                sourceDataLine.open(audioFormat);
                targetDataLine.start();
                sourceDataLine.start();
                FloatControl fc=(FloatControl)sourceDataLine.getControl(FloatControl.Type.MASTER_GAIN);
                double value=0.2;
                float dB = (float)(Math.log(value==0.0?0.0001:value)/Math.log(10.0)*20.0);
                fc.setValue(dB);
                int nByte = 0;
                final int bufSize=1024;
                byte[] buffer = new byte[bufSize];
                while (nByte != -1) {
                    //System.in.read();
                    nByte = targetDataLine.read(buffer, 0, bufSize);
                    sourceDataLine.write(buffer, 0, nByte);
                }
                sourceDataLine.stop();        } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
      

  2.   

    好像IBM有提供一些开发包的,可以在网上查查看
      

  3.   

    我知道ibm有过语音识别的软件,这样的东西不会免费的......
      

  4.   

    关注一下,看看csdn有没牛人。
    话说这个不好做啊。语音识别,文字识别,图像识别类似之类的东西做好了都会很值钱的。