在C或Java或PHP语音识别? [英] Speech recognition in C or Java or PHP?

查看:176
本文介绍了在C或Java或PHP语音识别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有知名的既定框架为C或Java或PHP做语音识别应用?麦克风音频输入接口,它可以识别英文单词。如伪code:

 语音S =新的语音();
s.input(micStream);
结果= s.recognise(你好);
如果(结果){printf的(你好匹配); }其他{printf的(无匹配找到); }

后续:

下载:<一href=\"http://sourceforge.net/projects/cmusphinx/files/sphinx4/1.0%20beta6/\">sphinx4/1.0%20beta6/


  1. 添加库


  2. 复制和放大器;贴code:

    一个)xml文件放某处,它可以从code加载

    https://gist.github.com/2551321

    二)使用:

     包edu.cmu.sphinx.demo.hellowrld;
    进口edu.cmu.sphinx.frontend.util.Microphone;
    进口edu.cmu.sphinx.recognizer.Recognizer;
    进口edu.cmu.sphinx.result.Result;
    进口edu.cmu.sphinx.util.props.ConfigurationManager;
    进口java.io.IOException异常;
    进口java.util.logging.Level中;
    进口java.util.logging.Logger中;
    进口models.Tts;公共类语音{  公共静态无效的主要(字串[] args){
        ConfigurationManager中厘米;    如果(args.length大于0){
            厘米=新ConfigurationManager中(参数[0]);
        }其他{
            ///tmp/helloworld.config.xml
            厘米=新ConfigurationManager中(Speech.class.getResource(speech.config.xml));    }
        识别器识别=(识别器)cm.lookup(识别);
        recognizer.allocate();    麦克风麦克风=(麦克风)cm.lookup(话筒);
        如果(!microphone.startRecording()){
            的System.out.println(无法启动麦克风。);
            recognizer.deallocate();
            System.exit(1);
        }    的System.out.println(说:(你好|调用)(纳摩| BAAM | CAAM |部分));    而(真){
            的System.out.println(开始讲preSS按Ctrl-C退出\\ n。);        结果结果= recognizer.recognize();        如果(结果!= NULL){
                串resultText = result.getBestFinalResultNoFiller();
                的System.out.println(你说:+ resultText +的'\\ n');                TTS TS =新TTS();
                    尝试{
                        ts.load();
                        ts.say(你说:+ resultText);
                    }赶上(IOException异常前){                }
            }其他{
                的System.out.println(我不能听你说的话\\ n);
            }
        }
      }
    }



解决方案

检查了这一点: http://cmusphinx.sourceforge.net/

Is there any well known established framework for C or Java or PHP to do speech recognition applications? Microphone audio input and it will recognize English words. Such as pseudo code:

Speech s = new Speech();
s.input(micStream);
result = s.recognise("Hello");
if (result) { printf("Matched hello"); } else { printf("No match found"); }

Follow up:

Download this: sphinx4/1.0%20beta6/

  1. Add the libraries

  2. Copy & paste code:

    a) xml file put somewhere, which can be loaded from the code:

    https://gist.github.com/2551321

    b) use this:

    package edu.cmu.sphinx.demo.hellowrld;
    import edu.cmu.sphinx.frontend.util.Microphone;
    import edu.cmu.sphinx.recognizer.Recognizer;
    import edu.cmu.sphinx.result.Result;
    import edu.cmu.sphinx.util.props.ConfigurationManager;
    import java.io.IOException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import models.Tts;
    
    public class Speech {
    
      public static void main(String[] args) {
        ConfigurationManager cm;
    
        if (args.length > 0) {
            cm = new ConfigurationManager(args[0]);
        } else {
            ///tmp/helloworld.config.xml
            cm = new ConfigurationManager(Speech.class.getResource("speech.config.xml"));
    
        }
        Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
        recognizer.allocate();
    
        Microphone microphone = (Microphone) cm.lookup("microphone");
        if (!microphone.startRecording()) {
            System.out.println("Cannot start microphone.");
            recognizer.deallocate();
            System.exit(1);
        }
    
        System.out.println("Say: (Hello | call) ( Naam | Baam | Caam | Some )");
    
        while (true) {
            System.out.println("Start speaking. Press Ctrl-C to quit.\n");
    
            Result result = recognizer.recognize();
    
            if (result != null) {
                String resultText = result.getBestFinalResultNoFiller();
                System.out.println("You said: " + resultText + '\n');
    
                    Tts ts = new Tts();
                    try {
                        ts.load();
                        ts.say("Did you said: " + resultText);
                    } catch (IOException ex) {
    
                    } 
            } else {
                System.out.println("I can't hear what you said.\n");
            }
        }
      }
    }
    

解决方案

Check this out: http://cmusphinx.sourceforge.net/

这篇关于在C或Java或PHP语音识别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆