Soniox Provider
Soniox Provider
Soniox provider는 Soniox 전사 모델을 Vercel AI SDK와 통합해요. 자세한 내용은 Soniox Documentation을 참고하세요.
출처: 문서
본문
설치
npm install @soniox/vercel-ai-sdk-provider
인증
환경에 SONIOX_API_KEY를 설정하거나 프로바이더를 만들 때 apiKey를 전달해요.
API 키는 Soniox Console에서 받을 수 있어요.
예시
import { soniox } from '@soniox/vercel-ai-sdk-provider';
import { transcribe } from 'ai';
const { text } = await transcribe({
model: soniox.transcription('stt-async-v3'),
audio: new URL('https://soniox.com/media/examples/coffee_shop.mp3'),
});
프로바이더 옵션
createSoniox를 사용해 프로바이더 인스턴스를 커스터마이즈해요:
import { createSoniox } from '@soniox/vercel-ai-sdk-provider';
const soniox = createSoniox({
apiKey: proces...KEY,
apiBaseUrl: 'https://api.soniox.com',
});
옵션:
apiKey:SONIOX_API_KEY를 재정의해요.apiBaseUrl: 커스텀 API 기본 URL. 리전별 API 엔드포인트 목록은 여기를 참고하세요.headers: 추가 요청 헤더.fetch: 커스텀 fetch 구현.pollingIntervalMs: 전사 폴링 간격(밀리초). 기본값은 1000ms예요.
전사 옵션
요청별 옵션은 providerOptions를 통해 전달돼요:
const { text } = await transcribe({
model: soniox.transcription('stt-async-v3'),
audio,
providerOptions: {
soniox: {
languageHints: ['en', 'es'],
enableLanguageIdentification: true,
enableSpeakerDiarization: true,
context: {
terms: ['Soniox', 'Vercel'],
},
},
},
});
사용 가능한 옵션:
languageHints- 인식을 편향시키는 ISO 언어 코드 배열languageHintsStrict- true일 때 언어 힌트에 더 크게 의존 (일부 모델에서 미지원)enableLanguageIdentification- 말하는 언어를 자동 감지enableSpeakerDiarization- 서로 다른 화자를 식별하고 분리context- 정확도를 높이는 추가 컨텍스트clientReferenceId- 선택적인 클라이언트 정의 참조 IDwebhookUrl- 전사 완료 알림을 위한 웹훅 URLwebhookAuthHeaderName- 웹훅 인증 헤더 이름webhookAuthHeaderValue- 웹훅 인증 헤더 값translation- 번역 설정
자세한 내용은 Soniox API reference를 확인하세요.
언어 힌트
Soniox는 60개 이상의 언어로 음성을 자동 감지하고 전사해요. 오디오에 나타날 가능성이 있는 언어를 안다면 languageHints를 제공해 인식을 해당 언어 쪽으로 편향시켜 정확도를 높일 수 있어요.
언어 힌트는 인식을 제한하지 않아요 — 단지 모델을 지정된 언어 쪽으로 편향시킬 뿐이며, 다른 언어가 있다면 여전히 감지할 수 있어요.
const { text } = await transcribe({
model: soniox.transcription('stt-async-v3'),
audio,
providerOptions: {
soniox: {
languageHints: ['en', 'es'], // ISO language codes
},
},
});
자세한 내용은 Soniox language hints 문서를 참고하세요.
컨텍스트
전사 및 번역 정확도를 높이기 위해 커스텀 컨텍스트를 제공해요. 컨텍스트는 모델이 도메인을 이해하고, 중요한 용어를 인식하며, 커스텀 어휘를 적용하도록 도와줘요.
context 객체는 네 개의 선택 섹션을 지원해요:
const { text } = await transcribe({
model: soniox.transcription('stt-async-v3'),
audio,
providerOptions: {
soniox: {
context: {
// Structured key-value information (domain, topic, intent, etc.)
general: [
{ key: 'domain', value: 'Healthcare' },
{ key: 'topic', value: 'Diabetes management consultation' },
{ key: 'doctor', value: 'Dr. Martha Smith' },
],
// Longer free-form background text or related documents
text: 'The patient has a history of...',
// Domain-specific or uncommon words
terms: ['Celebrex', 'Zyrtec', 'Xanax'],
// Custom translations for ambiguous terms
translationTerms: [
{ source: 'Mr. Smith', target: 'Sr. Smith' },
{ source: 'MRI', target: 'RM' },
],
},
},
},
});
자세한 내용은 Soniox context 문서를 참고하세요.
더 알아보기 (Learn more)
- 출처 문서: Soniox Provider