From a0cb1fd718dca2b783283e7a9cb68a159c388ded Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 25 Aug 2025 12:22:38 -0700 Subject: [PATCH 1/5] added auto as option --- src/audio/interfaces.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/interfaces.ts b/src/audio/interfaces.ts index 22198e3..c9a192b 100644 --- a/src/audio/interfaces.ts +++ b/src/audio/interfaces.ts @@ -3,7 +3,7 @@ import { BaseResponse } from "../../types"; export interface SpeechToTextParams { url?: string; file_store_key?: string; - language?: string; + language?: string | "auto"; translate?: boolean; by_speaker?: boolean; webhook_url?: string; From 87e7729d9e63a5ecd3855892245849d6145bebf9 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 25 Aug 2025 12:32:04 -0700 Subject: [PATCH 2/5] update test --- tests/audio.test.ts | 103 +++++++++----------------------------------- 1 file changed, 21 insertions(+), 82 deletions(-) diff --git a/tests/audio.test.ts b/tests/audio.test.ts index c67061b..7a0aba7 100644 --- a/tests/audio.test.ts +++ b/tests/audio.test.ts @@ -66,86 +66,25 @@ describe("STT APIs", () => { expectProperty(result, "text"); expectType(result.text, "string"); }); -}); -// describe("TTS APIs", () => { -// let client: ReturnType; - -// beforeEach(() => { -// client = createJigsawStackClient(); -// }); - -// test("text to speech basic", async () => { -// const result = await client.audio.text_to_speech({ -// text: text, -// accent: "en-US-female-3", -// }); - -// // TTS returns a file choice object -// expectProperty(result, "blob"); -// expectType(result.blob, "function"); -// expectProperty(result, "buffer"); -// expectType(result.buffer, "function"); -// expectProperty(result, "file"); -// expectType(result.file, "function"); -// }); - -// test("text to speech with different accent", async () => { -// const result = await client.audio.text_to_speech({ -// text: text, -// accent: "en-GB-male-2", -// }); - -// // TTS returns a file choice object -// expectProperty(result, "blob"); -// expectType(result.blob, "function"); -// }); - -// test("text to speech with return type base64", async () => { -// const result = await client.audio.text_to_speech({ -// text: text, -// accent: "en-US-female-3", -// return_type: "base64", -// }); - -// // TTS returns a file choice object -// expectProperty(result, "url"); -// expectType(result.url, "string"); -// }); - -// test("text to speech with return type binary", async () => { -// const result = await client.audio.text_to_speech({ -// text: text, -// accent: "en-US-female-3", -// return_type: "binary", -// }); - -// // TTS returns a file choice object -// expectProperty(result, "blob"); -// expectType(result.blob, "function"); -// }); - -// test("get speaker voice accents", async () => { -// const result = await client.audio.speaker_voice_accents(); - -// expectSuccess(result); -// expectType(result, "object"); -// }); - -// test("list voice clones", async () => { -// const result = await client.audio.list_clones({ -// limit: 10, -// page: 0, -// }); - -// expectSuccess(result); -// expectType(result, "object"); -// }); - -// test("list voice clones with default params", async () => { -// const result = await client.audio.list_clones(); - -// expectSuccess(result); -// expectType(result, "object"); -// }); -// }); + test("speech to text with auto language", async () => { + const result = await client.audio.speech_to_text({ + url: audioUrl, + language: "auto", + }); + + expectSuccess(result); + expectProperty(result, "text"); + expectType(result.text, "string"); + }); + + test("speech to text with invalid language", async () => { + const result = await client.audio.speech_to_text({ + url: audioUrl, + }); + + expectSuccess(result); + expectProperty(result, "text"); + expectType(result.text, "string"); + }); +}); From bdcbae150cad58d2337a4ab3ed6d45ec0ad1dcf4 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 25 Aug 2025 12:41:19 -0700 Subject: [PATCH 3/5] swapped url for working test --- tests/vision.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/vision.test.ts b/tests/vision.test.ts index 5cba11c..afaf537 100644 --- a/tests/vision.test.ts +++ b/tests/vision.test.ts @@ -2,10 +2,9 @@ import { beforeEach, describe, test } from "node:test"; import { createJigsawStackClient, expectArray, expectProperty, expectSuccess, expectType } from "./test-helpers.js"; const TEST_URLS = { - image: "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png", + image: "https://jigsawstack.com/preview/object-detection-example-input.jpg", pdf: "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf", textImage: "https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Vd-Orig.png/256px-Vd-Orig.png", - receipt: "https://jigsawstack.com/preview/receipt-example.jpg", // Example receipt image }; // Comprehensive VOCR API Tests From 8262a4ab8e0b049db93c37d812ecdde0c7b9699a Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 25 Aug 2025 14:00:00 -0700 Subject: [PATCH 4/5] language types addedc --- src/audio/interfaces.ts | 166 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 165 insertions(+), 1 deletion(-) diff --git a/src/audio/interfaces.ts b/src/audio/interfaces.ts index c9a192b..704f2a8 100644 --- a/src/audio/interfaces.ts +++ b/src/audio/interfaces.ts @@ -3,7 +3,7 @@ import { BaseResponse } from "../../types"; export interface SpeechToTextParams { url?: string; file_store_key?: string; - language?: string | "auto"; + language?: LanguageCodes | "auto"; translate?: boolean; by_speaker?: boolean; webhook_url?: string; @@ -39,6 +39,170 @@ export interface TextToSpeechParams { return_type?: "url" | "binary" | "base64"; } +export type LanguageCodes = + | "af" + | "am" + | "ar" + | "as" + | "az" + | "ba" + | "be" + | "bg" + | "bn" + | "bo" + | "br" + | "bs" + | "ca" + | "ch" + | "co" + | "cs" + | "cy" + | "da" + | "de" + | "dv" + | "dz" + | "el" + | "en" + | "eo" + | "es" + | "et" + | "eu" + | "fa" + | "ff" + | "fi" + | "fj" + | "fo" + | "fr" + | "fy" + | "ga" + | "gd" + | "gl" + | "gu" + | "gv" + | "ha" + | "he" + | "hi" + | "hr" + | "ht" + | "hu" + | "hy" + | "id" + | "ig" + | "is" + | "it" + | "iu" + | "ja" + | "jv" + | "ka" + | "kg" + | "ki" + | "kj" + | "kk" + | "kl" + | "km" + | "kn" + | "ko" + | "kr" + | "ks" + | "ku" + | "kv" + | "kw" + | "ky" + | "la" + | "lb" + | "lg" + | "li" + | "ln" + | "lo" + | "lt" + | "lu" + | "lv" + | "mg" + | "mh" + | "mi" + | "mk" + | "ml" + | "mn" + | "mo" + | "mr" + | "ms" + | "mt" + | "my" + | "na" + | "nb" + | "nd" + | "ne" + | "ng" + | "nl" + | "nn" + | "no" + | "nr" + | "nv" + | "ny" + | "oc" + | "oj" + | "om" + | "or" + | "os" + | "pa" + | "pi" + | "pl" + | "ps" + | "pt" + | "qu" + | "rm" + | "rn" + | "ro" + | "ru" + | "rw" + | "sa" + | "sc" + | "sd" + | "se" + | "sg" + | "sh" + | "si" + | "sk" + | "sl" + | "sm" + | "sn" + | "so" + | "sq" + | "sr" + | "ss" + | "st" + | "su" + | "sv" + | "sw" + | "ta" + | "te" + | "tg" + | "th" + | "ti" + | "tk" + | "tl" + | "tn" + | "to" + | "tr" + | "ts" + | "tt" + | "tw" + | "ty" + | "ug" + | "uk" + | "ur" + | "uz" + | "ve" + | "vi" + | "vo" + | "wo" + | "xh" + | "yi" + | "yo" + | "zh" + | "zh-TW" + | "zu"; + export interface TTSCloneParams { url?: string; file_store_key?: string; From a9472b4da63bbe8cce2a08d5247b4bb79960e181 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 25 Aug 2025 14:05:28 -0700 Subject: [PATCH 5/5] update vercel toolkit to match the language types --- src/vercel-ai-toolkit.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vercel-ai-toolkit.ts b/src/vercel-ai-toolkit.ts index 13a64ae..cd03e16 100644 --- a/src/vercel-ai-toolkit.ts +++ b/src/vercel-ai-toolkit.ts @@ -1,5 +1,6 @@ import { z } from "zod"; import { BaseConfig } from "../types"; +import { LanguageCodes } from "./audio/interfaces"; import { JigsawStack } from "./core"; import { tool } from "./vercel-tool"; @@ -283,7 +284,7 @@ export class JigsawStackToolSet { return await this.jigsawStack.audio.speech_to_text({ url, file_store_key, - language, + language: language as LanguageCodes | "auto", translate, by_speaker, });