Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 165 additions & 1 deletion src/audio/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BaseResponse } from "../../types";
export interface SpeechToTextParams {
url?: string;
file_store_key?: string;
language?: string;
language?: LanguageCodes | "auto";
translate?: boolean;
by_speaker?: boolean;
webhook_url?: string;
Expand Down Expand Up @@ -31,3 +31,167 @@ export interface SpeechToTextWebhookResponse extends BaseResponse {
status: "processing" | "error";
id: string;
}

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";
3 changes: 2 additions & 1 deletion src/vercel-ai-toolkit.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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,
});
Expand Down
21 changes: 21 additions & 0 deletions tests/audio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,25 @@ describe("STT APIs", () => {
expectProperty(result, "text");
expectType(result.text, "string");
});

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");
});
});
3 changes: 1 addition & 2 deletions tests/vision.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down