3

当我试图从下面的代码中获取输出时,它会提供来自Wave文件的文本文件,该文件通过RecordRTC从客户端传输到服务器,

      LibVosk.setLogLevel(LogLevel.DEBUG);

    try (Model model = new Model("model");
         InputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(filepath)));
         Recognizer recognizer = new Recognizer(model, 16000)) {

        int nbytes;
        byte[] b = new byte[4096];
        while ((nbytes = ais.read(b)) >= 0) {
            if (recognizer.acceptWaveForm(b, nbytes)) {
                System.out.println(recognizer.getResult());
            } else {
                System.out.println(recognizer.getPartialResult());
            }
        }

        System.out.println(recognizer.getFinalResult());
    }

它给出了这个输出,问题是最终结果是Empty

LOG (VoskAPI:ReadDataFiles():model.cc:211) Decoding params beam=10 max-active=3000 lattice-beam=2
LOG (VoskAPI:ReadDataFiles():model.cc:214) Silence phones 1:2:3:4:5:6:7:8:9:10
LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 1 orphan nodes.
LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 2 orphan components.
LOG (VoskAPI:Collapse():nnet-utils.cc:1488) Added 1 components, removed 2
LOG (VoskAPI:CompileLooped():nnet-compile-looped.cc:345) Spent 0.077131 seconds in looped compilation.
LOG (VoskAPI:ReadDataFiles():model.cc:238) Loading i-vector extractor from model/ivector/final.ie
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done.
LOG (VoskAPI:ReadDataFiles():model.cc:268) Loading HCLG from model/graph/HCLG.fst
LOG (VoskAPI:ReadDataFiles():model.cc:283) Loading words from model/graph/words.txt
LOG (VoskAPI:ReadDataFiles():model.cc:292) Loading winfo model/graph/phones/word_boundary.int
LOG (VoskAPI:ReadDataFiles():model.cc:299) Loading subtract G.fst model from model/rescore/G.fst
LOG (VoskAPI:ReadDataFiles():model.cc:301) Loading CARPA model from model/rescore/G.carpa


{
  "partial" : ""
}
{
  "partial" : ""
}
{
  "partial" : ""
}
{
  "partial" : ""
}
{
  "text" : ""
}
4

1 回答 1

1

我想我找到了答案,这是因为麦克风的采样率,

通过转到:声音>>录音>>单击麦克风>>高级

  • 你可以看到你的采样率

在此处输入图像描述 在此处输入图像描述

于 2022-01-25T13:07:51.413 回答