第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用PocketSphinx識(shí)別多個(gè)關(guān)鍵字

使用PocketSphinx識(shí)別多個(gè)關(guān)鍵字

開心每一天1111 2019-10-12 09:34:21
我已經(jīng)安裝了PocketSphinx演示程序,并且在Ubuntu和Eclipse下運(yùn)行良好,但是盡管嘗試了一下,但仍無(wú)法弄清楚如何添加多個(gè)單詞的識(shí)別。我只想讓代碼識(shí)別單個(gè)單詞,然后我就可以在代碼中識(shí)別它們switch(),例如“上”,“下”,“左”,“右”。我不想識(shí)別句子,只能識(shí)別單個(gè)單詞。任何幫助,將不勝感激。我發(fā)現(xiàn)其他用戶也有類似的問(wèn)題,但到目前為止,沒(méi)人知道答案。讓我感到困惑的一件事是,為什么我們根本需要使用“喚醒”常量?private static final String KWS_SEARCH = "wakeup";private static final String KEYPHRASE = "oh mighty computer";...recognizer.addKeyphraseSearch(KWS_SEARCH, KEYPHRASE);有wakeup什么關(guān)系嗎?我已經(jīng)取得了一些進(jìn)步(?):使用,addGrammarSearch我可以使用.gram文件列出我的單詞,例如up,down,left,right,forwards,backwards,如果我只說(shuō)那些特定的單詞,這似乎很好用。但是,任何其他字詞都將導(dǎo)致系統(tǒng)將所陳述的內(nèi)容與“最近”字詞進(jìn)行匹配。理想情況下,如果.gram文件中沒(méi)有說(shuō)出的單詞,我不希望被識(shí)別...
查看完整描述

3 回答

?
aluckdog

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個(gè)贊

您可以使用addKeywordSearch哪個(gè)用于歸檔密鑰短語(yǔ)。每行一個(gè)短語(yǔ),例如//中的每個(gè)短語(yǔ)都有閾值


up /1.0/

down /1.0/

left /1.0/

right /1.0/

forwards /1e-1/

必須選擇閾值以避免錯(cuò)誤警報(bào)。


查看完整回答
反對(duì) 回復(fù) 2019-10-12
?
蕭十郎

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超13個(gè)贊

正在為PocketSphinx演示更新Antinous修訂,以使其能夠在Android Studio上運(yùn)行。這就是我到目前為止


//Note: change MainActivity to PocketSphinxActivity for demo use...

public class MainActivity extends Activity implements RecognitionListener {

private static final String DIGITS_SEARCH = "digits";

private SpeechRecognizer recognizer;


/* Used to handle permission request */

private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 1;


@Override

public void onCreate(Bundle state) {

    super.onCreate(state);


    setContentView(R.layout.main);

    ((TextView) findViewById(R.id.caption_text))

            .setText("Preparing the recognizer");


    // Check if user has given permission to record audio

    int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.RECORD_AUDIO);

    if (permissionCheck != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST_RECORD_AUDIO);

        return;

    }


    new AsyncTask<Void, Void, Exception>() {

        @Override

        protected Exception doInBackground(Void... params) {

            try {

                Assets assets = new Assets(MainActivity.this);

                File assetDir = assets.syncAssets();

                setupRecognizer(assetDir);

            } catch (IOException e) {

                return e;

            }

            return null;

        }

        @Override

        protected void onPostExecute(Exception result) {

            if (result != null) {

                ((TextView) findViewById(R.id.caption_text))

                        .setText("Failed to init recognizer " + result);

            } else {

                reset();

            }

        }

    }.execute();

    ((TextView) findViewById(R.id.caption_text)).setText("Say one, two, three, four, five, six...");

}


/**

 * In partial result we get quick updates about current hypothesis. In

 * keyword spotting mode we can react here, in other modes we need to wait

 * for final result in onResult.

 */


@Override

public void onPartialResult(Hypothesis hypothesis) {

    if (hypothesis == null) {

        return;

    } else if (hypothesis != null) {

        if (recognizer != null) {

            //recognizer.rapidSphinxPartialResult(hypothesis.getHypstr());

            String text = hypothesis.getHypstr();

            if (text.equals(DIGITS_SEARCH)) {

                recognizer.cancel();

                performAction();

                recognizer.startListening(DIGITS_SEARCH);

            }else{

                //Toast.makeText(getApplicationContext(),"Partial result = " +text,Toast.LENGTH_SHORT).show();

            }

        }

    }

}

@Override

public void onResult(Hypothesis hypothesis) {

    ((TextView) findViewById(R.id.result_text)).setText("");

    if (hypothesis != null) {

        String text = hypothesis.getHypstr();

        makeText(getApplicationContext(), "Hypothesis" +text, Toast.LENGTH_SHORT).show();

    }else if(hypothesis == null){

        makeText(getApplicationContext(), "hypothesis = null", Toast.LENGTH_SHORT).show();

    }

}

@Override

public void onDestroy() {

    super.onDestroy();

    recognizer.cancel();

    recognizer.shutdown();

}

@Override

public void onBeginningOfSpeech() {

}

@Override

public void onEndOfSpeech() {

   reset();

}

@Override

public void onTimeout() {

}

private void setupRecognizer(File assetsDir) throws IOException {

    // The recognizer can be configured to perform multiple searches

    // of different kind and switch between them

    recognizer = defaultSetup()

            .setAcousticModel(new File(assetsDir, "en-us-ptm"))

            .setDictionary(new File(assetsDir, "cmudict-en-us.dict"))

            // .setRawLogDir(assetsDir).setKeywordThreshold(1e-20f)

            .getRecognizer();

    recognizer.addListener(this);


    File digitsGrammar = new File(assetsDir, "digits.gram");

    recognizer.addKeywordSearch(DIGITS_SEARCH, digitsGrammar);

}

private void reset(){

    recognizer.stop();

    recognizer.startListening(DIGITS_SEARCH);

}

@Override

public void onError(Exception error) {

    ((TextView) findViewById(R.id.caption_text)).setText(error.getMessage());

}


public void performAction() {

    // do here whatever you want

    makeText(getApplicationContext(), "performAction done... ", Toast.LENGTH_SHORT).show();

}

}

請(qǐng)注意:此工作正在進(jìn)行中。過(guò)一會(huì)再來(lái)檢查。建議將不勝感激。


查看完整回答
反對(duì) 回復(fù) 2019-10-12
  • 3 回答
  • 0 關(guān)注
  • 1285 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)