new(core.gbapp): Due to MSFT issue https://github.com/microsoft/cognitive-services-speech-sdk-js/issues/92 disabling AUDIO.
This commit is contained in:
parent
3abe85ca30
commit
e87031255e
7 changed files with 100 additions and 73 deletions
|
@ -534,7 +534,7 @@ export class GBConversationalService {
|
|||
language: string
|
||||
): Promise<string> {
|
||||
|
||||
if (process.env.TRANSLATOR_DISABLED === "true") {
|
||||
if (endPoint === null || process.env.TRANSLATOR_DISABLED === "true") {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
|
|
@ -165,6 +165,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
instance.adminPass = GBAdminService.getRndPassword();
|
||||
instance.title = botId;
|
||||
instance.activationCode = instance.botId;
|
||||
instance.state = 'active';
|
||||
|
||||
await this.core.saveInstance(instance);
|
||||
|
||||
|
|
|
@ -690,8 +690,11 @@ export class GBMinService {
|
|||
|
||||
let locale = 'pt';
|
||||
if (process.env.TRANSLATOR_DISABLED !== "true") {
|
||||
locale = await AzureText.getLocale(min.instance.textAnalyticsKey,
|
||||
min.instance.textAnalyticsEndpoint, query);
|
||||
const minBoot = GBServer.globals.minBoot as any; // TODO: Switch keys automatically to master/per bot.
|
||||
locale = await AzureText.getLocale(minBoot.instance.textAnalyticsKey ?
|
||||
minBoot.instance.textAnalyticsKey : minBoot.instance.textAnalyticsKey,
|
||||
minBoot.instance.textAnalyticsEndpoint ?
|
||||
minBoot.instance.textAnalyticsEndpoint : minBoot.instance.textAnalyticsKeyEndpoint, query);
|
||||
}
|
||||
|
||||
let sec = new SecService();
|
||||
|
|
|
@ -43,7 +43,7 @@ import { AzureText } from 'pragmatismo-io-framework';
|
|||
import { CSService } from '../services/CSService';
|
||||
import { Messages } from '../strings';
|
||||
import { SecService } from '../../security.gblib/services/SecService';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
||||
import { GBServer } from '../../../src/app';
|
||||
|
||||
/**
|
||||
* Dialog for feedback collecting.
|
||||
|
@ -137,10 +137,14 @@ export class FeedbackDialog extends IGBDialog {
|
|||
return await min.conversationalService.prompt(min, step, Messages[locale].what_about_service);
|
||||
},
|
||||
async step => {
|
||||
const minBoot = GBServer.globals.minBoot as any;
|
||||
|
||||
const locale = step.context.activity.locale;
|
||||
const rate = await AzureText.getSentiment(
|
||||
min.instance.textAnalyticsKey,
|
||||
min.instance.textAnalyticsEndpoint,
|
||||
minBoot.instance.textAnalyticsKey ?
|
||||
minBoot.instance.textAnalyticsKey : minBoot.instance.textAnalyticsKey,
|
||||
minBoot.instance.textAnalyticsEndpoint ?
|
||||
minBoot.instance.textAnalyticsEndpoint : minBoot.instance.textAnalyticsKeyEndpoint,
|
||||
min.conversationalService.getCurrentLanguage(step),
|
||||
step.result
|
||||
);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBLog, GBMinInstance, IGBDialog } from 'botlib';
|
||||
|
@ -105,8 +106,11 @@ export class AskDialog extends IGBDialog {
|
|||
|
||||
let locale = 'pt';
|
||||
if (process.env.TRANSLATOR_DISABLED !== "true") {
|
||||
locale = await AzureText.getLocale(min.instance.textAnalyticsKey,
|
||||
min.instance.textAnalyticsEndpoint, query);
|
||||
const minBoot = GBServer.globals.minBoot as any;
|
||||
locale = await AzureText.getLocale(minBoot.instance.textAnalyticsKey ?
|
||||
minBoot.instance.textAnalyticsKey : minBoot.instance.textAnalyticsKey,
|
||||
minBoot.instance.textAnalyticsEndpoint ?
|
||||
minBoot.instance.textAnalyticsEndpoint : minBoot.instance.textAnalyticsKeyEndpoint, query);
|
||||
}
|
||||
|
||||
let sec = new SecService();
|
||||
|
|
|
@ -55,6 +55,7 @@ import { Messages } from '../strings';
|
|||
import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
|
||||
import { CSService } from '../../customer-satisfaction.gbapp/services/CSService';
|
||||
import { SecService } from '../../security.gblib/services/SecService';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
|
||||
/**
|
||||
* Result for quey on KB data.
|
||||
|
@ -382,7 +383,7 @@ export class KBService implements IGBKBService {
|
|||
|
||||
await this.playMarkdown(min, answer, channel, step, min.conversationalService);
|
||||
|
||||
} else if (answer.content.endsWith('.ogg')) {
|
||||
} else if (answer.content.endsWith('.ogg') && process.env.AUDIO_DISABLED !== "true") {
|
||||
|
||||
await this.playAudio(min, answer, channel, step, min.conversationalService);
|
||||
} else {
|
||||
|
@ -476,7 +477,11 @@ export class KBService implements IGBKBService {
|
|||
|
||||
// Imports subjects tree into database and return it.
|
||||
|
||||
await this.importSubjectFile(packageStorage.packageId, urlJoin(localPath, 'subjects.json'), instance);
|
||||
const subjectFile = urlJoin(localPath, 'subjects.json');
|
||||
|
||||
if (Fs.existsSync(subjectFile)) {
|
||||
await this.importSubjectFile(packageStorage.packageId, subjectFile, instance);
|
||||
}
|
||||
|
||||
// Import tabular files in the tabular directory.
|
||||
|
||||
|
@ -493,9 +498,8 @@ export class KBService implements IGBKBService {
|
|||
public async importRemainingArticles(localPath: string, instance: IGBInstance, packageId: number): Promise<any> {
|
||||
const files = await walkPromise(urlJoin(localPath, 'articles'));
|
||||
|
||||
return Promise.all(
|
||||
files.map(async file => {
|
||||
if (file.name.endsWith('.md')) {
|
||||
await CollectionUtil.asyncForEach(files, async file => {
|
||||
if (file !== null && file.name.endsWith('.md')) {
|
||||
|
||||
let content = await this.getAnswerTextByMediaName(instance.instanceId, file.name);
|
||||
|
||||
|
@ -514,18 +518,25 @@ export class KBService implements IGBKBService {
|
|||
});
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
public async importKbTabularDirectory(localPath: string, instance: IGBInstance, packageId: number): Promise<any> {
|
||||
const files = await walkPromise(urlJoin(localPath, 'tabular'));
|
||||
let files = await walkPromise(localPath);
|
||||
|
||||
return Promise.all(
|
||||
files.map(async file => {
|
||||
if (file.name.endsWith('.xlsx')) {
|
||||
await CollectionUtil.asyncForEach(files, async file => {
|
||||
if (file !== null && file.name.endsWith('.xlsx')) {
|
||||
return await this.importKbTabularFile(urlJoin(file.root, file.name), instance.instanceId, packageId);
|
||||
}
|
||||
})
|
||||
);
|
||||
files = await walkPromise(urlJoin(localPath, 'tabular'));
|
||||
|
||||
await CollectionUtil.asyncForEach(files, async file => {
|
||||
|
||||
if (file !== null && file.name.endsWith('.xlsx')) {
|
||||
return await this.importKbTabularFile(urlJoin(file.root, file.name), instance.instanceId, packageId);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public async importSubjectFile(packageId: number, filename: string, instance: IGBInstance): Promise<any> {
|
||||
|
@ -582,7 +593,7 @@ export class KBService implements IGBKBService {
|
|||
const packageType = Path.extname(localPath);
|
||||
const packageName = Path.basename(localPath);
|
||||
GBLog.info(`[GBDeployer] Opening package: ${localPath}`);
|
||||
const packageObject = JSON.parse(Fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
||||
|
||||
|
||||
const instance = await core.loadInstanceByBotId(min.botId);
|
||||
GBLog.info(`[GBDeployer] Importing: ${localPath}`);
|
||||
|
|
|
@ -174,6 +174,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
const locale = user.locale ? user.locale : 'pt';
|
||||
if (message.type === "ptt") {
|
||||
|
||||
if (process.env.AUDIO_DISABLED !== "true") {
|
||||
const options = {
|
||||
url: message.body,
|
||||
method: 'GET',
|
||||
|
@ -187,7 +188,10 @@ export class WhatsappDirectLine extends GBService {
|
|||
this.min.instance.cloudLocation,
|
||||
buf, locale
|
||||
);
|
||||
|
||||
}
|
||||
else{
|
||||
await this.sendToDevice(user.userSystemId, `No momento estou apenas conseguindo ler mensagens de texto.`);
|
||||
}
|
||||
}
|
||||
|
||||
const conversationId = this.conversationIds[from];
|
||||
|
@ -422,7 +426,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
public async sendToDevice(to, msg) {
|
||||
|
||||
const cmd = '/audio ';
|
||||
if (msg.startsWith(cmd)) {
|
||||
if (msg.startsWith(cmd) && process.env.AUDIO_DISABLED !== 'true') {
|
||||
msg = msg.substr(cmd.length);
|
||||
return await this.sendTextAsAudioToDevice(to, msg);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue