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
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ To learn more about all available JigsawStack AI services, view the [Documentati
| ----------------- | -------------------------------------------------- |
| **👉 General** | Translation, Summarization, Sentiment Analysis |
| **🌐 Web** | AI Web Scraping, AI Web Search |
| **🎵 Audio** | Text to Speech, Speech to Text |
| **🎵 Audio** | Speech to Text |
| **👀 Vision** | vOCR, Object Detection |
| **🧠 LLMs** | Prompt Engine |
| **🖼️ Generative** | AI Image (Flux, SD, SDXL-Fast & more), HTML to Any |
| **✅ Validation** | Email, NSFW images, profanity & more |

Expand Down Expand Up @@ -63,13 +62,6 @@ const resp = await jigsaw.web.ai_scrape({
});
```

Text to Speech Example:

```ts
const resp = await jigsaw.audio.text_to_speech({
text: "Hello, how are you doing?",
});
```

Upload a file to use across any API example:

Expand Down
21 changes: 0 additions & 21 deletions src/audio/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,6 @@ class Audio {
}
return await this.client.fetchJSS("/ai/transcribe", "POST", params);
}

text_to_speech = async (params: TextToSpeechParams) => {
const resp = await this.client.fetchJSS("/ai/tts", "POST", params);
return respToFileChoice(resp);
};

speaker_voice_accents = async () => {
return await this.client.fetchJSS("/ai/tts", "GET");
};

create_clone = async (params: TTSCloneParams) => {
return await this.client.fetchJSS("/ai/tts/clone", "POST", params);
};

list_clones = async (params?: ListTTSVoiceClonesParams) => {
return await this.client.fetchJSS("/ai/tts/clone", "GET", undefined, params);
};

delete_clone = async (voice_id: string) => {
return await this.client.fetchJSS(`/ai/tts/clone/${voice_id}`, "DELETE");
};
}

export default Audio;
19 changes: 19 additions & 0 deletions src/classification/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { RequestClient } from "../request";
import { ClassificationImageParams, ClassificationResponse, ClassificationTextParams } from "./interfaces";

class Classification {
private readonly client: RequestClient;
constructor(client: RequestClient) {
this.client = client;
}

text = async (params: ClassificationTextParams): Promise<ClassificationResponse> => {
return await this.client.fetchJSS("/classification", "POST", params);
};

image = async (params: ClassificationImageParams): Promise<ClassificationResponse> => {
return await this.client.fetchJSS("/classification", "POST", params);
};
}

export default Classification;
31 changes: 31 additions & 0 deletions src/classification/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { BaseResponse } from "../../types";

export interface ClassificationResponse extends BaseResponse {
predictions: (string | string[])[];
}

export interface ClassificationTextParams {
dataset: Array<{
type: "text";
value: string;
}>;
labels: Array<{
key?: string;
type: "text";
value: string;
}>;
multiple_labels?: boolean;
}

export interface ClassificationImageParams {
dataset: Array<{
type: "image";
value: string;
}>;
labels: Array<{
key?: string;
type: "image" | "text";
value: string;
}>;
multiple_labels?: boolean;
}
3 changes: 0 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import "isomorphic-fetch";
import { BaseConfig } from "../types";
import AudioApis from "./audio/audio";
import General from "./general";
import PromptEngine from "./prompt_engine";
import { RequestClient } from "./request";
import { File } from "./store/file";
import Validate from "./validate";
Expand All @@ -21,7 +20,6 @@ export const JigsawStack = (config?: BaseConfig) => {
const web = new Web(client);
const vision = new Vision(client);
const audio = new AudioApis(client);
const promptengine = new PromptEngine(client);
const file = new File(client);
const validate = new Validate(client);
const store = {
Expand Down Expand Up @@ -50,7 +48,6 @@ export const JigsawStack = (config?: BaseConfig) => {
search: web.search,
search_suggestions: web.search_suggestions,
},
prompt_engine: promptengine,
store,
validate,
};
Expand Down
50 changes: 0 additions & 50 deletions src/prompt_engine/index.ts

This file was deleted.

69 changes: 0 additions & 69 deletions src/prompt_engine/interfaces.ts

This file was deleted.

24 changes: 0 additions & 24 deletions src/vercel-ai-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,30 +291,6 @@ export class JigsawStackToolSet {
},
}),

text_to_speech: tool({
description: "Convert text to speech",
parameters: z.object({
text: z.string().describe("Text to convert to speech"),
accent: z.string().optional().describe("Voice accent (see JigsawStack docs for supported accents)"),
voice_clone_id: z.string().optional().describe("ID of cloned voice to use"),
}),
execute: async ({ text, accent, voice_clone_id }) => {
await this.jigsawStack.audio.text_to_speech({
text,
accent: accent as SupportedAccents,
voice_clone_id,
});

return {
success: true,
message: "Successfully converted text to speech",
text_length: text.length,
accent_used: accent || "default",
note: "Audio has been generated. Use jigsawStack.audio.text_to_speech() directly to get the binary data.",
};
},
}),

// ========== VALIDATION TOOLS ==========
nsfw_detection: tool({
description: "Detect NSFW (Not Safe For Work) content in images",
Expand Down
16 changes: 16 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createJigsawStackClient } from "./tests/test-helpers";

const client = createJigsawStackClient();

const result = await client.classification.text({
dataset: [
{ type: "text" as const, value: "This is a great product! I love it." },
{ type: "text" as const, value: "This is a great product! I hate it." },
],
labels: [
{ key: "positive", type: "text" as const, value: "positive sentiment" },
{ key: "negative", type: "text" as const, value: "negative sentiment" },
],
});

console.log(result);
82 changes: 0 additions & 82 deletions tests/audio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,85 +67,3 @@ describe("STT APIs", () => {
expectType(result.text, "string");
});
});

// describe("TTS APIs", () => {
// let client: ReturnType<typeof createJigsawStackClient>;

// 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");
// });
// });
Loading