Skip to content

Commit 84cbddc

Browse files
Robert M OchshornRobert M Ochshorn
authored andcommitted
pass through error when no language model is provided
1 parent 9250042 commit 84cbddc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

gentle/language_model_transcribe.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def align_progress(audio_f, transcript, proto_langdir, nnet_dir, want_progress=F
6060
os.unlink(gen_hclg_filename)
6161

6262
def show_progress(tran, ms=None):
63+
if tran.get("error"):
64+
return tran
6365
if tran.get("preview") is not None:
6466
# Yield some partial information
6567
return {"preview": tran["preview"],
@@ -99,7 +101,9 @@ def _normal_transcribe(audio_f, proto_langdir, nnet_dir, want_progress=False):
99101
yield {
100102
"transcript": "",
101103
"words": [],
104+
"error": "No transcript provided."
102105
}
106+
return
103107

104108
try:
105109
k = standard_kaldi.Kaldi(nnet_dir, hclg_path, proto_langdir)

serve.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,18 @@ def save():
113113
want_progress=True)
114114
result = None
115115
for result in progress:
116-
if result.get("preview") is not None:
116+
if result.get("error") is not None:
117+
status["status"] = "ERROR"
118+
status["error"] = result["error"]
119+
120+
# Save the status so that errors are recovered on restart of the server
121+
# XXX: This won't work, because the endpoint will override this file
122+
# XXX(2): duplicated code.
123+
with open(os.path.join(outdir, 'status.json'), 'w') as jsfile:
124+
json.dump(status, jsfile, indent=2)
125+
return
126+
127+
elif result.get("preview") is not None:
117128
status["message"] = result["preview"]
118129
status["t"] = result["t"]
119130
else:

0 commit comments

Comments
 (0)