2

When i am trying to get output from the code below, that gives text file from Wave file that transfered from client to server through 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());
    }

it gives this output and the problem is the final result is 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" : ""
}

1 Answers1

0

I think I found the answer and it was because of sampleRate of mic,

by going to: sounds >> Recordings >> clicking on the Mic >> Advanced

  • you can see your sample rate

enter image description here enter image description here