new(all): TTS/STT on Whatsapp channel.
This commit is contained in:
parent
ec317fbd6d
commit
cb13d84abf
4 changed files with 19 additions and 7 deletions
|
@ -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) => {
|
||||||
|
|
|
@ -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({});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,7 +433,7 @@ export class GBMinService {
|
||||||
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');
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue