new(all): TTS/STT on Whatsapp channel.

This commit is contained in:
Rodrigo Rodriguez 2020-04-30 09:14:32 -03:00
parent ec317fbd6d
commit cb13d84abf
4 changed files with 19 additions and 7 deletions

View file

@ -147,7 +147,7 @@ export class GBConversationalService {
try { try {
speechConfig.speechSynthesisLanguage = locale; speechConfig.speechSynthesisLanguage = locale;
speechConfig.speechSynthesisVoiceName = "pt-BR-Daniel-Apollo" // pt-BR-HeloisaRUS; speechConfig.speechSynthesisVoiceName = "pt-BR-HeloisaRUS";
synthesizer.speakTextAsync(text, synthesizer.speakTextAsync(text,
(result) => { (result) => {

View file

@ -210,7 +210,15 @@ export class GBCoreService implements IGBCoreService {
* Loads all items to start several listeners. * Loads all items to start several listeners.
*/ */
public async loadInstances(): Promise<IGBInstance[]> { public async loadInstances(): Promise<IGBInstance[]> {
return GuaribasInstance.findAll({}); if (process.env.LOAD_ONLY !== undefined)
{
const options = { where: { botId: process.env.LOAD_ONLY } };
return GuaribasInstance.findAll(options);
}
else
{
return GuaribasInstance.findAll({});
}
} }
/** /**

View file

@ -163,6 +163,10 @@ export class GBMinService {
} }
else { else {
activeMin = GBServer.globals.minInstances.filter(p => p.botId === user.currentBotId)[0];; activeMin = GBServer.globals.minInstances.filter(p => p.botId === user.currentBotId)[0];;
if (activeMin === undefined) {
activeMin = GBServer.globals.minBoot;
await (activeMin as any).whatsAppDirectLine.sendToDevice(id, `O outro Bot que você estava falando(${user.currentBotId}), não está mais disponível. Agora você está falando comigo, ${activeMin.instance.title}...`);
}
await (activeMin as any).whatsAppDirectLine.received(req, res); await (activeMin as any).whatsAppDirectLine.received(req, res);
} }
} }
@ -416,7 +420,7 @@ export class GBMinService {
min.instance.whatsappServiceNumber, min.instance.whatsappServiceNumber,
min.instance.whatsappServiceUrl min.instance.whatsappServiceUrl
); );
await min.whatsAppDirectLine.setup(true); await min.whatsAppDirectLine.setup(true);
} }
else { else {
const minBoot = GBServer.globals.minBoot as any; const minBoot = GBServer.globals.minBoot as any;
@ -424,14 +428,14 @@ export class GBMinService {
new WhatsappDirectLine( new WhatsappDirectLine(
min, min,
min.botId, min.botId,
min.instance.webchatKey, min.instance.webchatKey,
minBoot.instance.whatsappServiceKey, minBoot.instance.whatsappServiceKey,
minBoot.instance.whatsappServiceNumber, minBoot.instance.whatsappServiceNumber,
minBoot.instance.whatsappServiceUrl minBoot.instance.whatsappServiceUrl
); );
await min.whatsAppDirectLine.setup(false); await min.whatsAppDirectLine.setup(false);
} }
min.userProfile = conversationState.createProperty('userProfile'); min.userProfile = conversationState.createProperty('userProfile');
const dialogState = conversationState.createProperty('dialogState'); const dialogState = conversationState.createProperty('dialogState');

View file

@ -320,7 +320,7 @@ export class WhatsappDirectLine extends GBService {
let url = await GBConversationalService.getAudioBufferFromText( let url = await GBConversationalService.getAudioBufferFromText(
this.min.instance.speechKey, this.min.instance.speechKey,
this.min.instance.cloudLocation, this.min.instance.cloudLocation,
msg, 'pt-br' msg, 'pt-BR'
); );
await this.sendFileToDevice(to, url, 'Audio', msg); await this.sendFileToDevice(to, url, 'Audio', msg);