Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie authored Jan 17, 2023
1 parent d0c7342 commit a16ae51
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 20 deletions.
49 changes: 32 additions & 17 deletions js/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@
}
}

if(this.debug){
console.log("Voco init response: ", body);
}


if('is_satellite' in body){
if(body['is_satellite']){
Expand All @@ -293,22 +297,25 @@
document.getElementById('extension-voco-content').classList.remove('extension-voco-show-tab-timers');
document.getElementById('extension-voco-content').classList.add('extension-voco-show-tab-satellites');
}
else{
// Not a satellite, so succesful injection matters
if('possible_injection_failure' in body && 'mqtt_connected' in body){
if(body.mqtt_connected == false){
//document.getElementById("extension-voco-mqtt-error").style.display = 'block';
}
else if(body.possible_injection_failure){
document.getElementById("extension-voco-injection-failure").style.display = 'block';
}
}
}

if('connected_satellites' in body){
this.show_connected_satellites( body['connected_satellites'], body['is_satellite'] );
}

}
else{
// Not a satellite, so succesful injection matters
if('possible_injection_failure' in body && 'mqtt_connected' in body){
if(body.mqtt_connected == false){
//document.getElementById("extension-voco-mqtt-error").style.display = 'block';
}
else if(body.possible_injection_failure){
document.getElementById("extension-voco-injection-failure").style.display = 'block';
}
}
console.error("voco: is_satellite was not in response?");
}

if('hostname' in body){
Expand All @@ -320,11 +327,15 @@
if('satellite_targets' in body){
//console.log("satellite_targets in body: " + body['satellite_targets']);
if(Object.keys(body['satellite_targets']).length > 0){
//console.log("A satellite is possible");
if(this.debug){
console.log("Voco: at least one potential main voco controller detected");
}
if('is_satellite' in body){
//console.log("is_satellite: " + body['is_satellite']);
if(body['is_satellite']){
//console.log("I am a satellite");
if(this.debug){
console.log("I am a satellite");
}
document.getElementById('extension-voco-select-satellite-checkbox').checked = true;
}
}
Expand All @@ -344,7 +355,9 @@
document.getElementById('extension-voco-server-list').innerHTML = list_html;
}
else{
//console.log("satellites length was 0 - no other potential satellites spotted");
if(this.debug){
console.log("Voco: satellites length was 0 - no other potential satellites/controllers spotted");
}
}
}
}
Expand All @@ -356,7 +369,6 @@

}).catch((e) => {
console.log("Error getting Voco init data: " , e);
//pre.innerText = "Error getting initial Voco data: " , e;
});


Expand Down Expand Up @@ -497,26 +509,29 @@
try{
if( main_view.classList.contains('selected') ){



if(this.busy_polling){
if(this.debug){
console.log("voco: was still polling, aborting new poll");
}
this.busy_polling_count++;

if(this.busy_polling_count > 10){
this.busy_polling = false;
this.busy_polling_count = 0;
if(this.debug){
console.log("Busy polling for over 20 seconds");
console.log("Busy polling for over 20 seconds. Resetting this.busy_polling");
}
document.getElementById('extension-voco-main-controller-not-responding').style.display = 'block';
document.getElementById('extension-voco-text-commands-container').style.display = 'none';
}
else{
return;
}

return;
}
else{
//console.log("starting poll");
document.getElementById('extension-voco-main-controller-not-responding').style.display = 'none';
}

var refresh_chat_members = false
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
}
},
"short_name": "Voco",
"version": "4.1.8",
"version": "4.1.9",
"web_accessible_resources": [
"css/*.css",
"images/*.svg",
Expand Down
12 changes: 11 additions & 1 deletion pkg/voco_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ def __init__(self, verbose=True):
#self.satellite_asr_payload = None # temporarily holds the ASR payload that the satellite passes on to the main controller
self.last_spoken_sentence = "" # Used to avoid speaking the same sentence twice in quick succession
self.last_spoken_sentence_time = 0 # Used to avoid speaking the same sentence twice in quick succession
self.previous_intent_callback_time = 0 # avoid "echo" problem where the main controller and a satellite both hear a command (sometimes slightly differently), which causes a command to be run twice in a row.

# MQTT client
self.mqtt_client = None
Expand Down Expand Up @@ -4006,8 +4007,8 @@ def on_second_message(self, client, userdata, msg):
self.injection_in_progress = False
# Voco is now really ready
if self.initial_injection_completed == False:
self.initial_injection_completed = True
self.speak_welcome_message()
self.initial_injection_completed = True
"""
if self.persistent_data['is_satellite']:
if self.DEBUG:
Expand Down Expand Up @@ -5100,6 +5101,15 @@ def parse_ping(self,payload,ping_type="ping"):
#

def master_intent_callback(self, intent_message, try_alternative=False): # Triggered everytime Snips succesfully recognizes a voice intent
if self.DEBUG:
print("in master_intent_callback")

# This is an imperfect way of handling the situation when the main controller and a satellite both hear a voice command. Oddly, in theory this "echo" problem should already be handled by Snips.
if time.time() - self.previous_intent_callback_time < 5:
if self.DEBUG:
print("master_intent_callback ran less than 5 seconds ago, ignoring this one.")
return
self.previous_intent_callback_time = time.time()

final_test = False # there is a main incoming intent, and potentially some alternatives that can ale be tested. If we're on the last alternative (and still haven't gotten a good match), then this will cause various failure-related voice message to be spoken.
this_is_origin_site = False # Whether the origin site of the intent (e.g. a satellite or the main controller) is the same site as this controller.
Expand Down
2 changes: 1 addition & 1 deletion pkg/voco_api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def handle_request(self, request):
return APIResponse(
status=500,
content_type='application/json',
content=json.dumps({'state': False, 'satellite_targets':{}, 'site_id':self.adapter.persistent_data[site_id] }),
content=json.dumps({'state': False, 'satellite_targets':self.adapter.satellite_targets, 'site_id':self.adapter.persistent_data[site_id] }),
)

else:
Expand Down

0 comments on commit a16ae51

Please sign in to comment.