Skip to content

holamago/audion-js-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Audion JavaScript SDK

음성 AI 구현의 복잡함을 없애고, 비즈니스 가능성을 확장하세요.

License Node version TypeScript ready

목차

요구사항

  • Node.js 18+ 또는 fetch/FormData를 기본 제공하는 환경
    • 브라우저: 최신 크롬, 사파리, 파이어폭스 등
    • Node.js: 18 이상 권장 (그 이하 버전은 fetch 폴리필 필요)
  • API 키 (Audion 서비스 등록 필요)
    • 회원가입 후 API Key 발급 받아야 합니다.

설치

의존성 추가 (권장)

npm

npm install audion

yarn

yarn add audion

pnpm

pnpm add audion

TypeScript 프로젝트에서도 바로 사용 가능합니다. (타입 정의가 함께 제공됩니다.)

소스에서 빌드

git clone https://github.com/holamago/audion-js-sdk.git
cd audion-js-sdk
npm install
npm run build

빠른 시작

1. 클라이언트 초기화

import { AudionClient } from "audion";

// API 키로 클라이언트 초기화
const client = new AudionClient("your-api-key-here");

CommonJS (Node.js)

const { AudionClient } = require("audion");

const client = new AudionClient("your-api-key-here");

2. 로컬 파일 처리

브라우저

import { AudionClient } from "audion";

const client = new AudionClient("your-api-key-here");

// 브라우저에서 파일 입력 처리
async function handleFileInput(event: Event) {
  const input = event.target as HTMLInputElement;
  
  if (!input.files || input.files.length === 0) return;
  
  const file = input.files[0];
  
  const result = await client.flow(
    "audion_vu",
    "file",
    file
  );
  
  console.log("처리 결과:", result);
}

3. URL 처리

// YouTube URL 처리
const result = await client.flow(
  "audion_vu",
  "url",
  "https://www.youtube.com/watch?v=your-video-id"
);

console.log(result);

API 문서

AudionClient

Audion 서비스의 메인 클라이언트 클래스입니다.

생성자

// 기본 생성자
new AudionClient(apiKey: string)

// 커스텀 URL과 함께
new AudionClient(apiKey: string, baseUrl: string)

// 모든 옵션과 함께
new AudionClient(apiKey: string, baseUrl: string, timeout: number)

매개변수:

  • apiKey (string, 필수): Audion 서비스 인증을 위한 API 키
  • baseUrl (string, 선택): 서버의 기본 URL. 기본값: https://audion.magovoice.com/api-key/v1
  • timeout (number, 선택): HTTP 요청 타임아웃(초). 기본값: 3600초 (1시간)

예외:

  • Error: apiKey가 제공되지 않았거나 공백인 경우
  • Error: 현재 환경에 fetch가 없고, AudionClientOptions.fetchFn이 제공되지 않은 경우

메서드

flow(flow, inputType, input)

지정된 플로우로 음성/비디오 처리를 실행합니다.

flow(flow: string, inputType: "file" | "url", input: string | File): Promise<FlowResponse>

매개변수:

  • flow (string): 실행할 플로우의 이름
    • 현재 지원하는 플로우:
      • audion_vu: Voice Understanding
      • audion_vh: Voice Highlight
    • Custom Flow 지원 가능 (email: contact@holamago.com)
  • inputType (string): 입력 타입. file 또는 url
  • input (string | File): 처리할 파일 또는 URL
    • inputType === "url": 처리할 URL (문자열)
    • inputType === "file": 브라우저의 File 객체 (<input type="file">에서 선택한 파일)

반환값:

  • Promise<FlowResponse>: 처리 결과를 포함하는 응답

예외:

  • Error: flow가 비어 있거나 공백 문자열인 경우
  • Error: inputType"file" 또는 "url"이 아닌 경우
  • Error: HTTP 요청 실패 시

사용 예제

호출 예시

Node.js에서 URL 기반 처리

import { AudionClient } from "audion";

async function main() {
  const apiKey = process.env.AUDION_API_KEY ?? "mk_test_your_api_key_here";
  
  if (!apiKey) {
    throw new Error("환경 변수 AUDION_API_KEY가 필요합니다.");
  }
  
  const client = new AudionClient(apiKey);
  
  const result = await client.flow(
    "audion_vu",
    "url",
    "https://www.youtube.com/watch?v=w3HrpxtvHxs"
  );
  
  console.log("[audion] 응답 수신");
  console.log(JSON.stringify(result, null, 2));
}

main().catch(console.error);

브라우저에서 파일 업로드

import { AudionClient } from "audion";

const client = new AudionClient("your-api-key-here");

async function run() {
  const input = document.querySelector('input[type="file"]') as HTMLInputElement | null;
  
  if (!input || !input.files || input.files.length === 0) {
    console.error("파일을 선택해 주세요.");
    return;
  }
  
  const file = input.files[0];
  
  try {
    const result = await client.flow("audion_vu", "file", file);
    console.log("처리 결과:", result);
  } catch (e) {
    console.error("처리 오류:", e);
  }
}

자세한 예제 코드는 Audion JavaScript SDK 저장소의 examples를 참고하세요.

라이선스

이 프로젝트는 Apache License 2.0 하에 라이선스됩니다.

지원

버전 히스토리

  • v0.1.0: 초기 릴리스
    • 기본 flow API 지원
    • 파일 및 URL 입력 지원
    • 다중 오디오/비디오 형식 지원
    • TypeScript 타입 정의 포함
    • 브라우저 및 Node.js 환경 지원

Made by MAGO

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published