Skip to content

Latest commit

 

History

History
252 lines (179 loc) · 17.5 KB

README.md

File metadata and controls

252 lines (179 loc) · 17.5 KB

Audio

(audio)

Overview

Turn audio into text or text into audio.

Available Operations

createSpeech

Generates audio from the input text.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.CreateSpeechResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

createTranscription

Transcribes audio into the input language.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.CreateTranscriptionResponseBody>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

createTranslation

Translates audio into English.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.CreateTranslationResponseBody>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*