shitton
This commit is contained in:
+12
-10
@@ -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 "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user