mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
Feature/azure custom stt (#171)
* gather/transcribe: support for azure custom speech models (endpoint id) * allow azure stt custom speech endpoint id to be passed as property in recognizer * fix to add custom stt endpoint to session speech credentials object
This commit is contained in:
@@ -549,7 +549,9 @@ class CallSession extends Emitter {
|
|||||||
return {
|
return {
|
||||||
speech_credential_sid: credential.speech_credential_sid,
|
speech_credential_sid: credential.speech_credential_sid,
|
||||||
api_key: credential.api_key,
|
api_key: credential.api_key,
|
||||||
region: credential.region
|
region: credential.region,
|
||||||
|
use_custom_stt: credential.use_custom_stt,
|
||||||
|
custom_stt_endpoint: credential.custom_stt_endpoint
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if ('wellsaid' === vendor) {
|
else if ('wellsaid' === vendor) {
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class TaskGather extends Task {
|
|||||||
this.requestSnr = recognizer.requestSnr || false;
|
this.requestSnr = recognizer.requestSnr || false;
|
||||||
this.initialSpeechTimeoutMs = recognizer.initialSpeechTimeoutMs || 0;
|
this.initialSpeechTimeoutMs = recognizer.initialSpeechTimeoutMs || 0;
|
||||||
this.azureServiceEndpoint = recognizer.azureServiceEndpoint;
|
this.azureServiceEndpoint = recognizer.azureServiceEndpoint;
|
||||||
|
this.azureSttEndpointId = recognizer.azureSttEndpointId;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.hints = [];
|
this.hints = [];
|
||||||
@@ -358,10 +359,18 @@ class TaskGather extends Task {
|
|||||||
else if ('microsoft' === this.vendor) {
|
else if ('microsoft' === this.vendor) {
|
||||||
this.bugname = 'azure_transcribe';
|
this.bugname = 'azure_transcribe';
|
||||||
if (this.sttCredentials) {
|
if (this.sttCredentials) {
|
||||||
|
const {api_key, region, use_custom_stt, custom_stt_endpoint} = this.sttCredentials;
|
||||||
|
|
||||||
Object.assign(opts, {
|
Object.assign(opts, {
|
||||||
'AZURE_SUBSCRIPTION_KEY': this.sttCredentials.api_key,
|
'AZURE_SUBSCRIPTION_KEY': api_key,
|
||||||
'AZURE_REGION': this.sttCredentials.region
|
'AZURE_REGION': region
|
||||||
});
|
});
|
||||||
|
if (this.azureSttEndpointId) {
|
||||||
|
Object.assign(opts, {'AZURE_SERVICE_ENDPOINT_ID': this.azureSttEndpointId});
|
||||||
|
}
|
||||||
|
else if (use_custom_stt && custom_stt_endpoint) {
|
||||||
|
Object.assign(opts, {'AZURE_SERVICE_ENDPOINT_ID': custom_stt_endpoint});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this.hints && this.hints.length > 0) {
|
if (this.hints && this.hints.length > 0) {
|
||||||
opts.AZURE_SPEECH_HINTS = this.hints.map((h) => h.trim()).join(',');
|
opts.AZURE_SPEECH_HINTS = this.hints.map((h) => h.trim()).join(',');
|
||||||
|
|||||||
@@ -497,6 +497,7 @@
|
|||||||
"requestSnr": "boolean",
|
"requestSnr": "boolean",
|
||||||
"initialSpeechTimeoutMs": "number",
|
"initialSpeechTimeoutMs": "number",
|
||||||
"azureServiceEndpoint": "string",
|
"azureServiceEndpoint": "string",
|
||||||
|
"azureSttEndpointId": "string",
|
||||||
"asrDtmfTerminationDigit": "string",
|
"asrDtmfTerminationDigit": "string",
|
||||||
"asrTimeout": "number"
|
"asrTimeout": "number"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class TaskTranscribe extends Task {
|
|||||||
this.requestSnr = recognizer.requestSnr || false;
|
this.requestSnr = recognizer.requestSnr || false;
|
||||||
this.initialSpeechTimeoutMs = recognizer.initialSpeechTimeoutMs || 0;
|
this.initialSpeechTimeoutMs = recognizer.initialSpeechTimeoutMs || 0;
|
||||||
this.azureServiceEndpoint = recognizer.azureServiceEndpoint;
|
this.azureServiceEndpoint = recognizer.azureServiceEndpoint;
|
||||||
|
this.azureSttEndpointId = recognizer.azureSttEndpointId;
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() { return TaskName.Transcribe; }
|
get name() { return TaskName.Transcribe; }
|
||||||
@@ -232,10 +233,17 @@ class TaskTranscribe extends Task {
|
|||||||
}
|
}
|
||||||
else if (this.vendor === 'microsoft') {
|
else if (this.vendor === 'microsoft') {
|
||||||
this.bugname = 'azure_transcribe';
|
this.bugname = 'azure_transcribe';
|
||||||
|
const {api_key, region, use_custom_stt, custom_stt_endpoint} = this.sttCredentials;
|
||||||
Object.assign(opts, {
|
Object.assign(opts, {
|
||||||
'AZURE_SUBSCRIPTION_KEY': this.sttCredentials.api_key,
|
'AZURE_SUBSCRIPTION_KEY': api_key,
|
||||||
'AZURE_REGION': this.sttCredentials.region
|
'AZURE_REGION': region
|
||||||
});
|
});
|
||||||
|
if (this.azureSttEndpointId) {
|
||||||
|
Object.assign(opts, {'AZURE_SERVICE_ENDPOINT_ID': this.azureSttEndpointId});
|
||||||
|
}
|
||||||
|
else if (use_custom_stt && custom_stt_endpoint) {
|
||||||
|
Object.assign(opts, {'AZURE_SERVICE_ENDPOINT_ID': custom_stt_endpoint});
|
||||||
|
}
|
||||||
if (this.hints && this.hints.length > 0) {
|
if (this.hints && this.hints.length > 0) {
|
||||||
opts.AZURE_SPEECH_HINTS = this.hints.map((h) => h.trim()).join(',');
|
opts.AZURE_SPEECH_HINTS = this.hints.map((h) => h.trim()).join(',');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ const speechMapper = (cred) => {
|
|||||||
const o = JSON.parse(decrypt(credential));
|
const o = JSON.parse(decrypt(credential));
|
||||||
obj.api_key = o.api_key;
|
obj.api_key = o.api_key;
|
||||||
obj.region = o.region;
|
obj.region = o.region;
|
||||||
|
obj.use_custom_stt = o.use_custom_stt;
|
||||||
|
obj.custom_stt_endpoint = o.custom_stt_endpoint;
|
||||||
}
|
}
|
||||||
else if ('wellsaid' === obj.vendor) {
|
else if ('wellsaid' === obj.vendor) {
|
||||||
const o = JSON.parse(decrypt(credential));
|
const o = JSON.parse(decrypt(credential));
|
||||||
|
|||||||
Reference in New Issue
Block a user