This commit is contained in:
2026-05-13 10:18:54 +03:00
parent cd8d2683c0
commit c5b61ee3d8
38 changed files with 3929 additions and 3718 deletions
+12 -10
View File
@@ -198,7 +198,7 @@ async function transcribeGeminiSpeech(audio: AiDownloadedFile, signal?: AbortSig
temperature: 0,
abortSignal: signal,
},
});
}) as unknown as GeminiSpeechResponse;
return {
provider: AiProvider.GEMINI,
@@ -240,17 +240,19 @@ async function transcribeOllamaSpeech(audio: AiDownloadedFile, signal?: AbortSig
};
}
function collectGeminiText(response: any): string {
if (typeof response?.text === "string") return response.text;
type GeminiSpeechResponse = {
text?: string;
candidates?: Array<{content?: {parts?: Array<{text?: string}>}}> ;
};
const candidates = response?.candidates ?? [];
const candidateText = candidates
.flatMap((candidate: any) => candidate?.content?.parts ?? [])
.map((part: any) => part?.text ?? "")
function collectGeminiText(response: GeminiSpeechResponse): string {
if (typeof response.text === "string") return response.text;
const candidateText = (response.candidates ?? [])
.flatMap(candidate => candidate.content?.parts ?? [])
.map(part => part.text ?? "")
.join("");
if (candidateText.trim()) return candidateText;
return (response?.candidates ?? [])
.map((output: any) => typeof output === "string" ? output : output?.content?.parts?.[0]?.text ?? "")
.join("");
return "";
}