Skip to content

Commit

Permalink
pass through error when no language model is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert M Ochshorn authored and Robert M Ochshorn committed Mar 2, 2016
1 parent 9250042 commit 84cbddc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gentle/language_model_transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def align_progress(audio_f, transcript, proto_langdir, nnet_dir, want_progress=F
os.unlink(gen_hclg_filename)

def show_progress(tran, ms=None):
if tran.get("error"):
return tran
if tran.get("preview") is not None:
# Yield some partial information
return {"preview": tran["preview"],
Expand Down Expand Up @@ -99,7 +101,9 @@ def _normal_transcribe(audio_f, proto_langdir, nnet_dir, want_progress=False):
yield {
"transcript": "",
"words": [],
"error": "No transcript provided."
}
return

try:
k = standard_kaldi.Kaldi(nnet_dir, hclg_path, proto_langdir)
Expand Down
13 changes: 12 additions & 1 deletion serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,18 @@ def save():
want_progress=True)
result = None
for result in progress:
if result.get("preview") is not None:
if result.get("error") is not None:
status["status"] = "ERROR"
status["error"] = result["error"]

# Save the status so that errors are recovered on restart of the server
# XXX: This won't work, because the endpoint will override this file
# XXX(2): duplicated code.
with open(os.path.join(outdir, 'status.json'), 'w') as jsfile:
json.dump(status, jsfile, indent=2)
return

elif result.get("preview") is not None:
status["message"] = result["preview"]
status["t"] = result["t"]
else:
Expand Down

0 comments on commit 84cbddc

Please sign in to comment.