(audio)
Turn audio into text or text into audio.
- createSpeech - Generates audio from the input text.
- createTranscription - Transcribes audio into the input language.
- createTranslation - Translates audio into English.
Generates audio from the input text.
import { ArgotOpenAi } from "argot-open-ai";
const argotOpenAi = new ArgotOpenAi({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const result = await argotOpenAi.audio.createSpeech({
model: "tts-1",
input: "<value>",
voice: "onyx",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { ArgotOpenAiCore } from "argot-open-ai/core.js";
import { audioCreateSpeech } from "argot-open-ai/funcs/audioCreateSpeech.js";
// Use `ArgotOpenAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const argotOpenAi = new ArgotOpenAiCore({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const res = await audioCreateSpeech(argotOpenAi, {
model: "tts-1",
input: "<value>",
voice: "onyx",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.CreateSpeechRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.CreateSpeechResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
Transcribes audio into the input language.
import { ArgotOpenAi } from "argot-open-ai";
import { openAsBlob } from "node:fs";
const argotOpenAi = new ArgotOpenAi({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const result = await argotOpenAi.audio.createTranscription({
file: await openAsBlob("example.file"),
model: "whisper-1",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { ArgotOpenAiCore } from "argot-open-ai/core.js";
import { audioCreateTranscription } from "argot-open-ai/funcs/audioCreateTranscription.js";
import { openAsBlob } from "node:fs";
// Use `ArgotOpenAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const argotOpenAi = new ArgotOpenAiCore({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const res = await audioCreateTranscription(argotOpenAi, {
file: await openAsBlob("example.file"),
model: "whisper-1",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.CreateTranscriptionRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.CreateTranscriptionResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |
Translates audio into English.
import { ArgotOpenAi } from "argot-open-ai";
import { openAsBlob } from "node:fs";
const argotOpenAi = new ArgotOpenAi({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const result = await argotOpenAi.audio.createTranslation({
file: await openAsBlob("example.file"),
model: "whisper-1",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { ArgotOpenAiCore } from "argot-open-ai/core.js";
import { audioCreateTranslation } from "argot-open-ai/funcs/audioCreateTranslation.js";
import { openAsBlob } from "node:fs";
// Use `ArgotOpenAiCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const argotOpenAi = new ArgotOpenAiCore({
apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "",
});
async function run() {
const res = await audioCreateTranslation(argotOpenAi, {
file: await openAsBlob("example.file"),
model: "whisper-1",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.CreateTranslationRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.CreateTranslationResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
errors.SDKError | 4XX, 5XX | */* |