dont include language when no text was detected

This commit is contained in:
artie 2025-02-11 21:27:33 +01:00
parent 79a0a61a15
commit 1d628e5722

View File

@ -27,7 +27,7 @@ export function buildOcrPayload(
try {
return (
new Intl.DisplayNames(["en"], { type: "language" }).of(language) ??
"unknown"
"Unknown"
);
} catch {
return "Unknown";
@ -54,12 +54,15 @@ export function buildOcrPayload(
{
description: text,
color: model === "yandex" ? 0xffdb4d : 0x4285f4,
fields: [
fields:
text !== "No text detected"
? [
{
name: "Detected language",
value: languageName,
},
],
]
: [],
...(imageUrl ? { image: { url: imageUrl } } : {}),
author: {
name: capitalize(model),