From 17ca4c7c937cd1b084d51302db0fe0f14e298c3d Mon Sep 17 00:00:00 2001 From: Reynaldi Chernando <12949382+reynaldichernando@users.noreply.github.com> Date: Sat, 13 Dec 2025 03:55:51 +0700 Subject: [PATCH] Fix speech2txt options (#2150) --- src/puter-js/types/modules/ai.d.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/puter-js/types/modules/ai.d.ts b/src/puter-js/types/modules/ai.d.ts index 9b54ce7a..85a63f94 100644 --- a/src/puter-js/types/modules/ai.d.ts +++ b/src/puter-js/types/modules/ai.d.ts @@ -121,11 +121,16 @@ export interface Txt2SpeechOptions { test_mode?: boolean; } -export interface Speech2TxtOptions { +export interface Speech2TxtResult { + text: string; + language: string; + segments?: Record[]; +} + +interface BaseSpeech2TxtOptions { file?: string | File | Blob; audio?: string | File | Blob; model?: string; - response_format?: string; language?: string; prompt?: string; stream?: boolean; @@ -140,6 +145,14 @@ export interface Speech2TxtOptions { test_mode?: boolean; } +export interface TextFormatSpeech2TxtOptions extends BaseSpeech2TxtOptions { + response_format: "text"; +} + +export interface Speech2TxtOptions extends BaseSpeech2TxtOptions { + response_format?: Exclude; +} + export interface Speech2SpeechOptions { audio?: string | File | Blob; file?: string | File | Blob; @@ -197,9 +210,11 @@ export class AI { txt2vid (prompt: string, options: Txt2VidOptions): Promise; txt2vid (options: Txt2VidOptions, testMode?: boolean): Promise; - speech2txt (source: string | File | Blob, testMode?: boolean): Promise>; - speech2txt (source: string | File | Blob, options: Speech2TxtOptions, testMode?: boolean): Promise>; - speech2txt (options: Speech2TxtOptions, testMode?: boolean): Promise>; + speech2txt (source: string | File | Blob, testMode?: boolean): Promise; + speech2txt (source: string | File | Blob, options: TextFormatSpeech2TxtOptions, testMode?: boolean): Promise; + speech2txt (source: string | File | Blob, options: Speech2TxtOptions, testMode?: boolean): Promise; + speech2txt (options: TextFormatSpeech2TxtOptions, testMode?: boolean): Promise; + speech2txt (options: Speech2TxtOptions, testMode?: boolean): Promise; speech2speech (source: string | File | Blob, testMode?: boolean): Promise; speech2speech (source: string | File | Blob, options: Speech2SpeechOptions, testMode?: boolean): Promise;