⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basegrammar.java

📁 It is the Speech recognition software. It is platform independent. To execute the source code,
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }//////////////////////// End utility methods for sending GrammarEvents////////////////////////////////////////////// Begin utility methods for sending ResultEvents//////////////////////    /**     * Utility function to generate AUDIO_RELEASED event and post it     * to the event queue.  Eventually fireAudioReleased will be called     * by dispatchSpeechEvent as a result of this action.     */    public void postAudioReleased(Result result) {        SpeechEventUtilities.postSpeechEvent(            this,            new ResultEvent(result, ResultEvent.AUDIO_RELEASED));    }    /**     * Utility function to send a AUDIO_RELEASED event to all result     * listeners.       */    public void fireAudioReleased(ResultEvent event) {        Enumeration E;	if (resultListeners != null) {            E = resultListeners.elements();            while (E.hasMoreElements()) {                ResultListener rl = (ResultListener) E.nextElement();                rl.audioReleased(event);            }        }    }    /**     * Utility function to generate GRAMMAR_FINALIZED event and post it     * to the event queue.  Eventually fireGrammarFinalized will be called     * by dispatchSpeechEvent as a result of this action.     */    public void postGrammarFinalized(Result result) {        SpeechEventUtilities.postSpeechEvent(            this,            new ResultEvent(result, ResultEvent.GRAMMAR_FINALIZED));    }    /**     * Utility function to send a GRAMMAR_FINALIZED event to all result     * listeners.       */    public void fireGrammarFinalized(ResultEvent event) {        Enumeration E;	if (resultListeners != null) {            E = resultListeners.elements();            while (E.hasMoreElements()) {                ResultListener rl = (ResultListener) E.nextElement();                rl.grammarFinalized(event);            }        }    }    /**     * Utility function to generate RESULT_ACCEPTED event and post it     * to the event queue.  Eventually fireResultAccepted will be called     * by dispatchSpeechEvent as a result of this action.     */    public void postResultAccepted(Result result) {        SpeechEventUtilities.postSpeechEvent(            this,            new ResultEvent(result, ResultEvent.RESULT_ACCEPTED));    }    /**     * Utility function to send a RESULT_ACCEPTED event to all result     * listeners.       */    public void fireResultAccepted(ResultEvent event) {        Enumeration E;	if (resultListeners != null) {            E = resultListeners.elements();            while (E.hasMoreElements()) {                ResultListener rl = (ResultListener) E.nextElement();                rl.resultAccepted(event);            }        }    }    /**     * Utility function to generate RESULT_CREATED event and post it     * to the event queue.  Eventually fireResultCreated will be called     * by dispatchSpeechEvent as a result of this action.     */    public void postResultCreated(Result result) {        SpeechEventUtilities.postSpeechEvent(            this,            new ResultEvent(result, ResultEvent.RESULT_CREATED));    }    /**     * Utility function to send a RESULT_CREATED event to all result     * listeners.       */    public void fireResultCreated(ResultEvent event) {        Enumeration E;	if (resultListeners != null) {            E = resultListeners.elements();            while (E.hasMoreElements()) {                ResultListener rl = (ResultListener) E.nextElement();                rl.resultCreated(event);            }        }    }    /**     * Utility function to generate RESULT_REJECTED event and post it     * to the event queue.  Eventually fireResultRejected will be called     * by dispatchSpeechEvent as a result of this action.     */    public void postResultRejected(Result result) {        SpeechEventUtilities.postSpeechEvent(            this,            new ResultEvent(result, ResultEvent.RESULT_REJECTED));    }    /**     * Utility function to send a RESULT_REJECTED event to all result     * listeners.       */    public void fireResultRejected(ResultEvent event) {        Enumeration E;	if (resultListeners != null) {            E = resultListeners.elements();            while (E.hasMoreElements()) {                ResultListener rl = (ResultListener) E.nextElement();                rl.resultRejected(event);            }        }    }    /**     * Utility function to generate RESULT_UPDATED event and post it     * to the event queue.  Eventually fireResultUpdated will be called     * by dispatchSpeechEvent as a result of this action.     */    public void postResultUpdated(Result result) {        SpeechEventUtilities.postSpeechEvent(            this,            new ResultEvent(result, ResultEvent.RESULT_UPDATED));    }    /**     * Utility function to send a RESULT_UPDATED event to all result     * listeners.       */    public void fireResultUpdated(ResultEvent event) {        Enumeration E;	if (resultListeners != null) {            E = resultListeners.elements();            while (E.hasMoreElements()) {                ResultListener rl = (ResultListener) E.nextElement();                rl.resultUpdated(event);            }        }    }    /**     * Utility function to generate TRAINING_INFO_RELEASED event and post it     * to the event queue.  Eventually fireTrainingInfoReleased will be called     * by dispatchSpeechEvent as a result of this action.     */    public void postTrainingInfoReleased(Result result) {        SpeechEventUtilities.postSpeechEvent(            this,            new ResultEvent(result, ResultEvent.TRAINING_INFO_RELEASED));    }    /**     * Utility function to send a TRAINING_INFO_RELEASED event to all result     * listeners.       */    public void fireTrainingInfoReleased(ResultEvent event) {        Enumeration E;	if (resultListeners != null) {            E = resultListeners.elements();            while (E.hasMoreElements()) {                ResultListener rl = (ResultListener) E.nextElement();                rl.trainingInfoReleased(event);            }        }    }//////////////////////// End utility methods for sending ResultEvents////////////////////////////////////////////// NON-JSAPI METHODS//////////////////////    /**     * Set the name of this Grammar.     */    public void setName(String name) {        myName = name;    }    /**     * Dispatch a SpeechEvent.  This is a method from SpeechEventDispatcher.     * The dispatcher should notify all listeners of the speech event     * from this method.     */    public void dispatchSpeechEvent(SpeechEvent event) {        switch (event.getId()) {            case GrammarEvent.GRAMMAR_ACTIVATED:                fireGrammarActivated((GrammarEvent) event);                break;            case GrammarEvent.GRAMMAR_CHANGES_COMMITTED:                fireGrammarChangesCommitted((GrammarEvent) event);                break;            case GrammarEvent.GRAMMAR_DEACTIVATED:                fireGrammarDeactivated((GrammarEvent) event);                break;                            case ResultEvent.AUDIO_RELEASED:                fireAudioReleased((ResultEvent) event);                break;            case ResultEvent.GRAMMAR_FINALIZED:                fireGrammarFinalized((ResultEvent) event);                break;            case ResultEvent.RESULT_ACCEPTED:                fireResultAccepted((ResultEvent) event);                break;            case ResultEvent.RESULT_CREATED:                fireResultCreated((ResultEvent) event);                break;            case ResultEvent.RESULT_REJECTED:                fireResultRejected((ResultEvent) event);                break;            case ResultEvent.RESULT_UPDATED:                fireResultUpdated((ResultEvent) event);                break;            case ResultEvent.TRAINING_INFO_RELEASED:                fireTrainingInfoReleased((ResultEvent) event);                break;        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -