support google version 2 (#699)

* support google version 2

* update new parameters for google v2
This commit is contained in:
Hoan Luu Huu
2024-04-02 18:33:22 +07:00
committed by GitHub
parent 5b1d8a8ff3
commit 93d0e41e31
3 changed files with 23 additions and 20 deletions

View File

@@ -487,14 +487,10 @@ module.exports = (logger) => {
};
if ('google' === vendor) {
const model = task.name === TaskName.Gather ? 'command_and_search' : 'latest_long';
/**
* When we support google v2 the models are different and we will want something like:
* const useV2 = sttCredentials?.credentials?.project_id; //TODO: v2 pref should be set in googleOptions
* const model = task.name === TaskName.Gather ?
* (useV2 ? 'telephony_short' : 'command_and_search') :
* (useV2 ? 'long' : 'latest_long');
*/
const useV2 = rOpts.googleOptions?.serviceVersion === 'v2';
const model = task.name === TaskName.Gather ?
(useV2 ? 'telephony_short' : 'command_and_search') :
(useV2 ? 'long' : 'latest_long');
opts = {
...opts,
...(sttCredentials && {GOOGLE_APPLICATION_CREDENTIALS: JSON.stringify(sttCredentials.credentials)}),
@@ -527,12 +523,19 @@ module.exports = (logger) => {
...{GOOGLE_SPEECH_MODEL: rOpts.model || model},
...(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_CLOUD_SERVICES_VERSION: 'v2'
GOOGLE_SPEECH_CLOUD_SERVICES_VERSION: 'v2',
...(rOpts.googleOptions?.speechStartTimeoutMs && {
GOOGLE_SPEECH_START_TIMEOUT_MS: rOpts.googleOptions.speechStartTimeoutMs
}),
...(rOpts.googleOptions?.speechEndTimeoutMs && {
GOOGLE_SPEECH_END_TIMEOUT_MS: rOpts.googleOptions.speechEndTimeoutMs
}),
...(rOpts.googleOptions?.transcriptNormalization && {
GOOGLE_SPEECH_TRANSCRIPTION_NORMALIZATION: JSON.stringify(rOpts.googleOptions.transcriptNormalization)
})
}),
*/
};
}
else if (['aws', 'polly'].includes(vendor)) {

14
package-lock.json generated
View File

@@ -18,7 +18,7 @@
"@jambonz/speech-utils": "^0.0.44",
"@jambonz/stats-collector": "^0.1.9",
"@jambonz/time-series": "^0.2.8",
"@jambonz/verb-specifications": "^0.0.64",
"@jambonz/verb-specifications": "^0.0.66",
"@opentelemetry/api": "^1.4.0",
"@opentelemetry/exporter-jaeger": "^1.9.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.35.0",
@@ -3514,9 +3514,9 @@
}
},
"node_modules/@jambonz/verb-specifications": {
"version": "0.0.64",
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.64.tgz",
"integrity": "sha512-cW9wci240vSkVqVhN/B0MnJYXL4vUCAOia0ccNlVDiQmrcED3hFU1IkFXHRzyY5uiD+GaoapXUOqaerjbDtmLA==",
"version": "0.0.66",
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.66.tgz",
"integrity": "sha512-K1+7PCoKAEw/sOhqRFD6FjZHt/G9I0kaM24Zrh//W1zblc9jXvg8YIn1Hwx94yXemWMkqNNrmJsnyL9haOi5rg==",
"dependencies": {
"debug": "^4.3.4",
"pino": "^8.8.0"
@@ -14183,9 +14183,9 @@
}
},
"@jambonz/verb-specifications": {
"version": "0.0.64",
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.64.tgz",
"integrity": "sha512-cW9wci240vSkVqVhN/B0MnJYXL4vUCAOia0ccNlVDiQmrcED3hFU1IkFXHRzyY5uiD+GaoapXUOqaerjbDtmLA==",
"version": "0.0.66",
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.66.tgz",
"integrity": "sha512-K1+7PCoKAEw/sOhqRFD6FjZHt/G9I0kaM24Zrh//W1zblc9jXvg8YIn1Hwx94yXemWMkqNNrmJsnyL9haOi5rg==",
"requires": {
"debug": "^4.3.4",
"pino": "^8.8.0"

View File

@@ -34,7 +34,7 @@
"@jambonz/speech-utils": "^0.0.44",
"@jambonz/stats-collector": "^0.1.9",
"@jambonz/time-series": "^0.2.8",
"@jambonz/verb-specifications": "^0.0.64",
"@jambonz/verb-specifications": "^0.0.66",
"@opentelemetry/api": "^1.4.0",
"@opentelemetry/exporter-jaeger": "^1.9.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.35.0",