UNPKG

@lobehub/tts

Version:

A high-quality & reliable TTS React Hooks library

46 lines (44 loc) 1.32 kB
import edgeVoiceList_default from "./edgeVoiceList.mjs"; import voiceList_default from "../data/voiceList.mjs"; import { arrayBufferConvert } from "../utils/arrayBufferConvert.mjs"; import { getVoiceLocaleOptions } from "../utils/getVoiceList.mjs"; import { createEdgeSpeech } from "./createEdgeSpeech.mjs"; import { getEdgeVoiceOptions } from "./options.mjs"; //#region src/core/EdgeSpeechTTS/index.ts var EdgeSpeechTTS = class { constructor({ serviceUrl, locale, headers } = {}) { this.fetch = async (payload) => { return await (this.serviceUrl ? fetch(this.serviceUrl, { body: JSON.stringify(payload), headers: this.headers, method: "POST" }) : createEdgeSpeech({ payload })); }; this.create = async (payload) => { return this.fetch(payload); }; this.createAudio = async (payload) => { return arrayBufferConvert(await (await this.create(payload)).arrayBuffer()); }; this.locale = locale; this.serviceUrl = serviceUrl; this.headers = headers; } get voiceOptions() { return getEdgeVoiceOptions(this.locale); } static { this.localeOptions = getVoiceLocaleOptions(); } static { this.voiceList = edgeVoiceList_default; } static { this.voiceName = voiceList_default; } static { this.createRequest = createEdgeSpeech; } }; //#endregion export { EdgeSpeechTTS };