Skip to content

Instantly share code, notes, and snippets.

@lgutie16
Created October 21, 2017 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgutie16/cea416949c55449947355444f1b7351d to your computer and use it in GitHub Desktop.
Save lgutie16/cea416949c55449947355444f1b7351d to your computer and use it in GitHub Desktop.
Functions
//Agent key words
const agentKeyWords = [
"grabadas", "monitoreadas", "de acuerdo",
"ofrecemos", "ofrecer", "toma de datos", "Oportunidad", "llamada", "ofrecerle", "como esta",
"confirmar", "el motivo de esta llamada", "proceder", "podria", "me puede comentar", "me puede decir",
"adquirir", "tiene alguna duda", "tiene alguna inquietud", "comprende", "que duda tiene"
]
//Client key words
const clientKeyWords = [
"gracias", "no gracias", "me interesa", "no me interesa", "tengo una inquietud", "pero es que"
]
//Warning words
const warningWords = ["cedula", "telefono", "direccion"]
//Conversation
let conversation = [{"person": "", "frase": "" }]
// On doument load resolve the SDK dependecy
function Initialize(onComplete) {
require(["Speech.Browser.Sdk"], function (SDK) {
onComplete(SDK);
});
}
//Identify speaker
function RecognizePerson(frase) {
const agentWeight = agentKeyWords.filter((palabra)=>{
return frase.indexOf(palabra) !== -1
})
const clientWeight = clientKeyWords.filter((palabra)=>{
return frase.indexOf(palabra) !== -1
})
const speaker = agentWeight.length > clientWeight.length ? "Agent" : "Client"
console.log("agentWeight.length", agentWeight.length, "clientWeight.length", clientWeight.length, "-> Speaker: ", speaker)
return speaker
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment