0

我已经在一个应用程序中实现了 VOSK,基于android demo。目前,在收听输入时,麦克风会保持打开状态 5 秒钟,然后评估输入。我需要麦克风保持打开更长时间,即 10 秒。以下暂定对其没有影响。

private void startSttService(SingleEmitter<String> emitter, Bundle extras) {
        float sampleRate = 16000.0f;
        KaldiRecognizer rec;
        if (Objects.nonNull(extras) && extras.containsKey(EXTRA_GRAMMAR)) {
            rec = new KaldiRecognizer(VoskModel.getModel(), sampleRate, extras.getString(EXTRA_GRAMMAR));
        } else {
            rec = new KaldiRecognizer(VoskModel.getModel(), sampleRate);
        }

        int speechServiceTimeout;
        if (Objects.nonNull(extras) && extras.containsKey(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS)) {
            speechServiceTimeout = (int) extras.getLong(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS);
        } else {
            speechServiceTimeout = 10000;
        }

帮助 :(

4

0 回答 0