java - C、Java 或 PHP 中的语音识别?

标签 java php c speech-recognition

是否有任何众所周知的 C 或 Java 或 PHP 框架来执行语音识别应用程序?麦克风音频输入,它会识别英文单词。如伪代码:

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

跟进:

下载:sphinx4/1.0%20beta6/

enter image description here

  1. 添加库

  2. 复制粘贴代码:

    a) xml 文件放在某处,可以从代码中加载:

    https://gist.github.com/2551321

    b) 使用这个:

    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");
            }
        }
      }
    }
    

最佳答案

关于java - C、Java 或 PHP 中的语音识别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6151385/

相关文章:

php - MySQLI 问题

Java inputevents 在 linux 中有一段时间没有触发(java/xorg 问题??)

php - jQuery 提交前确认

php - PHP 中的可变变量允许使用非法变量名吗?

c - 为什么 char * c = NULL;导致以下代码出错?

c - 使用 scanf 将字符串存储在结构中

将双变量与C中的整数值进行比较

java - JPA:Read Lock 是如何工作的?

java - 从 Java 中的 BigDecimal 中删除尾随零

java - 如何使用 Apache POI 获取 MS Excel 单元格的别名