@lobehub/tts
Version:
A high-quality & reliable TTS React Hooks library
49 lines (47 loc) • 1.43 kB
JavaScript
import voiceList_default from "../data/voiceList.mjs";
import { arrayBufferConvert } from "../utils/arrayBufferConvert.mjs";
import { getVoiceLocaleOptions } from "../utils/getVoiceList.mjs";
import styleList_default from "../data/styleList.mjs";
import { createMicrosoftSpeech } from "./createMicrosoftSpeech.mjs";
import azureVoiceList, { getAzureVoiceOptions } from "./voiceList.mjs";
//#region src/core/MicrosoftSpeechTTS/index.ts
var MicrosoftSpeechTTS = 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"
}) : createMicrosoftSpeech({ payload }));
};
this.create = async (payload) => {
return await 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 getAzureVoiceOptions(this.locale);
}
static {
this.localeOptions = getVoiceLocaleOptions();
}
static {
this.createRequest = createMicrosoftSpeech;
}
static {
this.voiceList = azureVoiceList;
}
static {
this.voiceName = voiceList_default;
}
static {
this.styleList = styleList_default;
}
};
//#endregion
export { MicrosoftSpeechTTS };