@memori.ai/memori-react
Version:
[](https://www.npmjs.com/package/@memori.ai/memori-react)   => `https://${region}.tts.speech.microsoft.com/cognitiveservices/v1`,
outputFormat: 'audio-24khz-48kbitrate-mono-mp3'
},
openai: {
defaultVoice: DEFAULT_OPENAI_VOICE,
defaultModel: 'tts-1',
voices: OPENAI_VOICES.ALL,
endpoint: 'https://api.openai.com/v1/audio/speech'
}
};
export function getTTSVoice(lang, provider = 'azure', voiceType = 'FEMALE') {
const voiceLang = (lang || 'EN').toUpperCase();
if (provider.toLowerCase() === 'openai') {
const langMap = OPENAI_VOICES.RECOMMENDED[voiceLang] || OPENAI_VOICES.RECOMMENDED.DEFAULT;
return langMap[voiceType] || OPENAI_VOICES.RECOMMENDED.DEFAULT[voiceType] || DEFAULT_OPENAI_VOICE;
}
else {
const langVoices = AZURE_VOICES[voiceLang] || DEFAULT_AZURE_VOICE;
return langVoices[voiceType] || langVoices.FEMALE || DEFAULT_AZURE_VOICE.FEMALE;
}
}
export function isValidVoice(voice, provider) {
if (provider.toLowerCase() === 'openai') {
return OPENAI_VOICES.ALL.includes(voice);
}
return /^[a-z]{2}-[A-Z]{2}-[A-Za-z]+Neural$/.test(voice);
}
export function getDefaultVoice(provider, voiceType = 'FEMALE') {
if (provider.toLowerCase() === 'openai') {
return OPENAI_VOICES.RECOMMENDED.DEFAULT[voiceType] || DEFAULT_OPENAI_VOICE;
}
else {
return DEFAULT_AZURE_VOICE[voiceType] || DEFAULT_AZURE_VOICE.FEMALE;
}
}
export function getDefaultRegion(provider) {
return PROVIDER_CONFIG[provider].defaultRegion || null;
}
export function getDefaultModel(provider) {
return PROVIDER_CONFIG[provider].defaultModel || null;
}
export function ensureValidVoice(voice, provider, voiceType = 'FEMALE') {
if (!voice || !isValidVoice(voice, provider)) {
return getDefaultVoice(provider, voiceType);
}
return voice;
}
export function createTTSConfiguration(config) {
const provider = config.provider || 'azure';
const voiceType = config.voiceType || 'FEMALE';
return {
provider,
voice: config.voice || getDefaultVoice(provider, voiceType),
model: config.model || getDefaultModel(provider),
region: config.region || getDefaultRegion(provider),
tenant: config.tenant || 'www.aisuru.com',
voiceType
};
}
//# sourceMappingURL=ttsVoiceUtility.js.map