mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-07-04 19:21:53 +00:00
fix microsoft SST endpoint id is failed on validating speech credential (#554)
This commit is contained in:
@@ -747,7 +747,8 @@ router.get('/:sid/test', async(req, res) => {
|
|||||||
}
|
}
|
||||||
if (cred.use_for_stt) {
|
if (cred.use_for_stt) {
|
||||||
try {
|
try {
|
||||||
await testMicrosoftStt(logger, {api_key, region, use_custom_stt, custom_stt_endpoint_url});
|
await testMicrosoftStt(logger,
|
||||||
|
{api_key, region, use_custom_stt, custom_stt_endpoint, custom_stt_endpoint_url});
|
||||||
results.stt.status = 'ok';
|
results.stt.status = 'ok';
|
||||||
SpeechCredential.sttTestResult(sid, true);
|
SpeechCredential.sttTestResult(sid, true);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -262,10 +262,19 @@ const testDeepgramStt = async(logger, credentials) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const testMicrosoftStt = async(logger, credentials) => {
|
const testMicrosoftStt = async(logger, credentials) => {
|
||||||
const {api_key, region, use_custom_stt, custom_stt_endpoint_url} = credentials;
|
const {api_key, region, use_custom_stt, custom_stt_endpoint, custom_stt_endpoint_url} = credentials;
|
||||||
const speechConfig = use_custom_stt ? sdk.SpeechConfig.fromEndpoint(
|
// custom_stt_endpoint_url is a custom service host URL (fromEndpoint),
|
||||||
new URL(custom_stt_endpoint_url), api_key) :
|
// custom_stt_endpoint is a custom model/deployment id (endpointId on a region-based config)
|
||||||
sdk.SpeechConfig.fromSubscription(api_key, region);
|
let speechConfig;
|
||||||
|
if (use_custom_stt && custom_stt_endpoint_url) {
|
||||||
|
speechConfig = sdk.SpeechConfig.fromEndpoint(new URL(custom_stt_endpoint_url), api_key);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
speechConfig = sdk.SpeechConfig.fromSubscription(api_key, region);
|
||||||
|
if (use_custom_stt && custom_stt_endpoint) {
|
||||||
|
speechConfig.endpointId = custom_stt_endpoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
const audioConfig = sdk.AudioConfig.fromWavFileInput(fs.readFileSync(`${__dirname}/../../data/test_audio.wav`));
|
const audioConfig = sdk.AudioConfig.fromWavFileInput(fs.readFileSync(`${__dirname}/../../data/test_audio.wav`));
|
||||||
speechConfig.speechRecognitionLanguage = 'en-US';
|
speechConfig.speechRecognitionLanguage = 'en-US';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user