1

GRAM ファイルを使用して、Java で sphinx 4 を使用して音声認識にカスタム キーワードを追加する方法を知りたいと思っていましたか?

のように: public = (設定曲);

「曲を設定」した後、ユーザーが好きなことを何でも言うことができ、それでも解析されるようにするにはどうすればよいですか?

        URL url = LulzSpeech.class.getResource("lulzspeech.config.xml");;

        System.out.println("Loading input...");

        ConfigurationManager cm = new ConfigurationManager(url);

        Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
        Microphone microphone = (Microphone) cm.lookup("microphone");

        recognizer.allocate();

        if (microphone.startRecording()) {

            System.out.println("Loading input completed, mic working, ready!");

            try{
            while (true) {
                Thread.sleep(50);

                Result result = recognizer.recognize();

                if (result != null)
                    if(result.getBestFinalResultNoFiller().toLowerCase().contains(MainLulz.programName.toLowerCase()))
                        MainLulz.mainVoiceHandler.handleInput(result.getBestFinalResultNoFiller());
            }
            }catch(Exception e){
                e.printStackTrace();
            }
        } else {
            System.out.println("Cannot start microphone.");
            recognizer.deallocate();
            System.exit(1);
        }
    } catch (IOException e) {
        System.err.println("Problem when loading LulzSpeech input: " + e);
        e.printStackTrace();
    } catch (PropertyException e) {
        System.err.println("Problem configuring LulzSpeech input: " + e);
        e.printStackTrace();
    } catch (InstantiationException e) {
        System.err.println("Problem creating LulzSpeech input: " + e);
        e.printStackTrace();
    }
4

1 に答える 1

0

Sphinx-4 の現在のバージョンでは、キーワード検出機能は実装されていません。キーワードを簡単に検出することはできません。

于 2012-10-03T22:55:38.290 に答える