Spaces:
Running on Zero
Running on Zero
Commit ·
31190c1
1
Parent(s): 51c88b7
feat: Normalize output from processor.decode in transcribe function for consistent string handling
Browse files- app/services/asr.py +7 -3
app/services/asr.py
CHANGED
|
@@ -265,9 +265,13 @@ def transcribe(
|
|
| 265 |
**inputs,
|
| 266 |
max_new_tokens=max_new_tokens,
|
| 267 |
)
|
| 268 |
-
# Cohere's processor.decode
|
| 269 |
-
# (per the model card)
|
| 270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
return {
|
| 273 |
"transcript": text,
|
|
|
|
| 265 |
**inputs,
|
| 266 |
max_new_tokens=max_new_tokens,
|
| 267 |
)
|
| 268 |
+
# Cohere's processor.decode is given the generated tensor as-is
|
| 269 |
+
# (per the model card). For a batched [1, seq] output it returns a
|
| 270 |
+
# *list* of strings, so normalize to a single string.
|
| 271 |
+
decoded = _processor.decode(outputs, skip_special_tokens=True)
|
| 272 |
+
if isinstance(decoded, (list, tuple)):
|
| 273 |
+
decoded = decoded[0] if decoded else ""
|
| 274 |
+
text = decoded.strip()
|
| 275 |
|
| 276 |
return {
|
| 277 |
"transcript": text,
|