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
|
||||
}),
|
||||
|
||||
Generated
+4
-4
@@ -18,7 +18,7 @@
|
||||
"@jambonz/speech-utils": "^0.2.30",
|
||||
"@jambonz/stats-collector": "^0.1.10",
|
||||
"@jambonz/time-series": "^0.2.17",
|
||||
"@jambonz/verb-specifications": "^0.1.11",
|
||||
"@jambonz/verb-specifications": "^0.1.12",
|
||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||
"@opentelemetry/api": "^1.8.0",
|
||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||
@@ -1647,9 +1647,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jambonz/verb-specifications": {
|
||||
"version": "0.1.11",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.1.11.tgz",
|
||||
"integrity": "sha512-2YWqBXhLUD+WLipMdysE155eOSgFVW3id0l4Ci37OYELJIG+GeJYMubReSlMXthU/WoVk91ATu+XkSsjuVO1dg==",
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.1.12.tgz",
|
||||
"integrity": "sha512-Ddqk78om3k2l1Kj6IGB945W8KOOEwKPLxWeXao6H4jMCbrRponCN+gFOOFUC8q4KRmoe4yaQ6Y02UkejPtaYzQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4",
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
"@jambonz/speech-utils": "^0.2.30",
|
||||
"@jambonz/stats-collector": "^0.1.10",
|
||||
"@jambonz/time-series": "^0.2.17",
|
||||
"@jambonz/verb-specifications": "^0.1.11",
|
||||
"@jambonz/verb-specifications": "^0.1.12",
|
||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||
"@opentelemetry/api": "^1.8.0",
|
||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||
|
||||
Reference in New Issue
Block a user