mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-04 19:31:49 +00:00
wip
This commit is contained in:
+6
-7
@@ -19,8 +19,7 @@ const {
|
||||
createNuanceClient,
|
||||
createKryptonClient,
|
||||
createRivaClient,
|
||||
noopLogger,
|
||||
isValidHttpOrWsUrl
|
||||
noopLogger
|
||||
} = require('./utils');
|
||||
const getNuanceAccessToken = require('./get-nuance-access-token');
|
||||
const {
|
||||
@@ -313,22 +312,22 @@ const synthMicrosoft = async(logger, {
|
||||
filePath
|
||||
}) => {
|
||||
try {
|
||||
const {api_key: apiKey, region, use_custom_tts, custom_tts_endpoint} = credentials;
|
||||
const {api_key: apiKey, region, use_custom_tts, custom_tts_endpoint, custom_tts_endpoint_url} = credentials;
|
||||
const trimSilence = filePath.endsWith('.r8');
|
||||
let content = text;
|
||||
let speechConfig;
|
||||
if (use_custom_tts && isValidHttpOrWsUrl(custom_tts_endpoint)) {
|
||||
if (use_custom_tts && custom_tts_endpoint_url) {
|
||||
if (apiKey) {
|
||||
speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint, apiKey);
|
||||
speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint_url, apiKey);
|
||||
} else {
|
||||
speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint);
|
||||
speechConfig = SpeechConfig.fromEndpoint(custom_tts_endpoint_url);
|
||||
}
|
||||
} else {
|
||||
speechConfig = SpeechConfig.fromSubscription(apiKey, region);
|
||||
}
|
||||
speechConfig.speechSynthesisLanguage = language;
|
||||
speechConfig.speechSynthesisVoiceName = voice;
|
||||
if (use_custom_tts && !isValidHttpOrWsUrl(custom_tts_endpoint)) {
|
||||
if (use_custom_tts && custom_tts_endpoint) {
|
||||
speechConfig.endpointId = custom_tts_endpoint;
|
||||
|
||||
/**
|
||||
|
||||
+1
-8
@@ -106,12 +106,6 @@ const createRivaClient = async(rivaUri) => {
|
||||
return client;
|
||||
};
|
||||
|
||||
const isValidHttpOrWsUrl = (url) => {
|
||||
const pattern = new RegExp('^(https?:\/\/|wss?:\/\/)');
|
||||
return !!url.match(pattern);
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
makeSynthKey,
|
||||
makeNuanceKey,
|
||||
@@ -122,6 +116,5 @@ module.exports = {
|
||||
createRivaClient,
|
||||
makeBasicAuthHeader,
|
||||
NUANCE_AUTH_ENDPOINT,
|
||||
noopLogger,
|
||||
isValidHttpOrWsUrl
|
||||
noopLogger
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user