fix(all): Locale in Audio is dynamic.

This commit is contained in:
Rodrigo Rodriguez 2024-02-17 11:57:49 -03:00
parent 2bbbe502e6
commit bbc930407a
3 changed files with 13 additions and 1 deletions

View file

@ -121,6 +121,7 @@
"google-libphonenumber": "3.2.31",
"googleapis": "126.0.1",
"ibm-watson": "7.1.2",
"iso-639-1": "^3.1.1",
"join-images-updated": "1.1.4",
"js-md5": "0.8.3",
"just-indent": "0.0.1",

View file

@ -499,10 +499,12 @@ export class GBConversationalService {
url: process.env.WATSON_STT_URL
});
locale = GBUtil.getLocaleLanguageAndCountry(locale);
const params = {
audio: data,
contentType: 'audio/l16; rate=44100',
model: 'pt-BR_BroadbandModel'
model: `${locale}_BroadbandModel`
};
speechToText

View file

@ -33,6 +33,7 @@
*/
'use strict';
import iso6391 from 'iso-639-1';
export class GBUtil {
@ -94,4 +95,12 @@ export class GBUtil {
}
};
public static getLocaleLanguageAndCountry(locale) {
const iso6393Language = iso6391.getCode(locale);
if (iso6393Language) {
return iso6393Language + '-' + locale.toLowerCase();
} else {
return null;
}
}
}