Skip to content

Commit

Permalink
Update for lookahead in kaldi
Browse files Browse the repository at this point in the history
  • Loading branch information
nshmyrev committed Nov 25, 2019
1 parent 93ef15e commit 3934e8b
Show file tree
Hide file tree
Showing 6 changed files with 66,407 additions and 66,390 deletions.
Binary file modified aars/kaldi-android-5.2.aar
Binary file not shown.
12 changes: 9 additions & 3 deletions app/src/main/java/org/kaldi/demo/KaldiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ private static class RecognizeTask extends AsyncTask<Void, Void, String> {
protected String doInBackground(Void... params) {
KaldiRecognizer rec;
long startTime = System.currentTimeMillis();
StringBuilder result = new StringBuilder();
try {
rec = new KaldiRecognizer(activityReference.get().model);
rec = new KaldiRecognizer(activityReference.get().model, 16000.f);

InputStream ais = activityReference.get().getAssets().open("10001-90210-01803.wav");
if (ais.skip(44) != 44) {
Expand All @@ -135,12 +136,17 @@ protected String doInBackground(Void... params) {
byte[] b = new byte[4096];
int nbytes;
while ((nbytes = ais.read(b)) >= 0) {
rec.AcceptWaveform(b, nbytes);
if (rec.AcceptWaveform(b, nbytes)) {
result.append(rec.Result());
} else {
result.append(rec.PartialResult());
}
}
result.append(rec.FinalResult());
} catch (IOException e) {
return "";
}
return String.format(activityReference.get().getString(R.string.elapsed), rec.FinalResult(), (System.currentTimeMillis() - startTime));
return String.format(activityReference.get().getString(R.string.elapsed), result.toString(), (System.currentTimeMillis() - startTime));
}

@Override
Expand Down
Binary file modified models/src/main/assets/sync/model-android/Gr.fst
Binary file not shown.
Binary file modified models/src/main/assets/sync/model-android/HCLr.fst
Binary file not shown.
11 changes: 11 additions & 0 deletions models/src/main/assets/sync/model-android/disambig_tid.int
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
Loading

0 comments on commit 3934e8b

Please sign in to comment.