Fix: Avoid runtime error when candidate is empty.
Browse files
app.py
CHANGED
@@ -18,8 +18,11 @@ def load_conette(*args, **kwargs) -> CoNeTTEModel:
|
|
18 |
return conette(*args, **kwargs)
|
19 |
|
20 |
|
21 |
-
def
|
22 |
-
|
|
|
|
|
|
|
23 |
|
24 |
|
25 |
def get_results(
|
@@ -136,7 +139,7 @@ def main() -> None:
|
|
136 |
audio_fnames, cands = get_results(model, audios, generate_kwds)
|
137 |
|
138 |
for audio_fname, cand in zip(audio_fnames, cands):
|
139 |
-
st.success(f"**Output for {audio_fname}:**\n- {
|
140 |
|
141 |
if len(record) > 0:
|
142 |
outputs = model(
|
@@ -145,7 +148,7 @@ def main() -> None:
|
|
145 |
)
|
146 |
cand = outputs["cands"][0]
|
147 |
st.success(
|
148 |
-
f"**Output for {osp.basename(record_fpath)}:**\n- {
|
149 |
)
|
150 |
|
151 |
|
|
|
18 |
return conette(*args, **kwargs)
|
19 |
|
20 |
|
21 |
+
def format_candidate(candidate: str) -> str:
|
22 |
+
if len(candidate) == 0:
|
23 |
+
return ""
|
24 |
+
else:
|
25 |
+
return f"{candidate[0].title()}{candidate[1:]}."
|
26 |
|
27 |
|
28 |
def get_results(
|
|
|
139 |
audio_fnames, cands = get_results(model, audios, generate_kwds)
|
140 |
|
141 |
for audio_fname, cand in zip(audio_fnames, cands):
|
142 |
+
st.success(f"**Output for {audio_fname}:**\n- {format_candidate(cand)}")
|
143 |
|
144 |
if len(record) > 0:
|
145 |
outputs = model(
|
|
|
148 |
)
|
149 |
cand = outputs["cands"][0]
|
150 |
st.success(
|
151 |
+
f"**Output for {osp.basename(record_fpath)}:**\n- {format_candidate(cand)}"
|
152 |
)
|
153 |
|
154 |
|