mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-07-04 19:32:01 +00:00
support recognizer.googleOptions.parentPath (#1546)
* support recognizer.googleOptions.parentPath * update vẻb specification * wip
This commit is contained in:
@@ -822,9 +822,22 @@ module.exports = (logger) => {
|
||||
|
||||
if ('google' === vendor) {
|
||||
const useV2 = rOpts.googleOptions?.serviceVersion === 'v2';
|
||||
const {parentPath} = rOpts.googleOptions || {};
|
||||
const version = useV2 ? 'v2' : 'v1';
|
||||
let {model} = rOpts;
|
||||
model = model || selectDefaultGoogleModel(task, language, version);
|
||||
|
||||
/**
|
||||
* For STT v2, Google routes regional resources only via regional endpoints.
|
||||
* A parentPath ending in `/locations/<region>` (anything other than `global`)
|
||||
* requires the request to go to `<region>-speech.googleapis.com` instead of
|
||||
* the default `speech.googleapis.com`.
|
||||
*/
|
||||
let derivedSttUri;
|
||||
if (useV2 && parentPath) {
|
||||
const m = parentPath.match(/\/locations\/([^/]+)/);
|
||||
if (m && m[1] && m[1] !== 'global') derivedSttUri = `${m[1]}-speech.googleapis.com`;
|
||||
}
|
||||
opts = {
|
||||
...opts,
|
||||
...(sttCredentials && {GOOGLE_APPLICATION_CREDENTIALS: JSON.stringify(sttCredentials.credentials)}),
|
||||
@@ -858,8 +871,10 @@ module.exports = (logger) => {
|
||||
...(rOpts.naicsCode > 0 && {GOOGLE_SPEECH_METADATA_INDUSTRY_NAICS_CODE: rOpts.naicsCode}),
|
||||
GOOGLE_SPEECH_METADATA_RECORDING_DEVICE_TYPE: 'phone_line',
|
||||
...(useV2 && {
|
||||
GOOGLE_SPEECH_RECOGNIZER_PARENT: `projects/${sttCredentials.credentials.project_id}/locations/global`,
|
||||
GOOGLE_SPEECH_RECOGNIZER_PARENT: parentPath ||
|
||||
`projects/${sttCredentials.credentials.project_id}/locations/global`,
|
||||
GOOGLE_SPEECH_CLOUD_SERVICES_VERSION: 'v2',
|
||||
...(derivedSttUri && {GOOGLE_SPEECH_TO_TEXT_URI: derivedSttUri}),
|
||||
...(rOpts.googleOptions?.speechStartTimeoutMs && {
|
||||
GOOGLE_SPEECH_START_TIMEOUT_MS: rOpts.googleOptions.speechStartTimeoutMs
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user