Skip to content

Commit

Permalink
lang from session
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 28, 2022
1 parent 81bb7cd commit f8cd161
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mycroft/listener/mic.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from ovos_config.locations import get_xdg_data_save_path
from mycroft.util.audio_utils import play_audio_file
from ovos_plugin_manager.vad import OVOSVADFactory
from ovos_utils.messagebus import get_message_lang
from ovos_bus_client.util import get_message_lang

WakeWordData = namedtuple('WakeWordData',
['audio', 'found', 'stopped', 'end_audio'])
Expand Down
4 changes: 3 additions & 1 deletion mycroft/skills/intent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from mycroft.util.log import LOG
from mycroft.util.audio_utils import play_error_sound
from mycroft.util.parse import normalize
from ovos_utils.messagebus import get_message_lang
from ovos_bus_client.util import get_message_lang
from ovos_bus_client.session import SessionManager


Expand Down Expand Up @@ -286,6 +286,8 @@ def handle_utterance(self, message):
"""
try:
lang = get_message_lang(message)
sess = SessionManager.get(message)
sess.lang = lang # update session object
try:
setup_locale(lang)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion mycroft/skills/intent_services/commonqa_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from mycroft.skills.skill_data import CoreResources
from ovos_utils.enclosure.api import EnclosureAPI
from ovos_utils.log import LOG
from ovos_utils.messagebus import get_message_lang
from ovos_bus_client.util import get_message_lang

EXTENSION_TIME = 10

Expand Down
12 changes: 9 additions & 3 deletions mycroft/skills/intent_services/converse_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ def activate_skill(self, skill_id, source_skill=None, message=None):
# also update default session
if session.session_id != SessionManager.default_session.session_id:
SessionManager.default_session.activate_skill(skill_id)

if message:
msg = message.forward("intent.service.skills.activated",
{"skill_id": skill_id})
else:
msg = Message("intent.service.skills.activated",
{"skill_id": skill_id})
# send bus event
self.bus.emit(
Message("intent.service.skills.activated",
{"skill_id": skill_id}))
self.bus.emit(msg)
# update activation counter
self._consecutive_activations[skill_id] += 1

Expand Down Expand Up @@ -250,6 +255,7 @@ def converse(self, utterances, skill_id, lang, message):
handled (bool): True if handled otherwise False.
"""
session = SessionManager.get(message)
session.lang = lang
state = session.utterance_states.get(skill_id, UtteranceState.INTENT)
if state == UtteranceState.RESPONSE:
session.update_history(message)
Expand Down
2 changes: 1 addition & 1 deletion mycroft/skills/mycroft_skill/mycroft_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from ovos_config.locations import get_xdg_config_save_path
from ovos_utils.enclosure.api import EnclosureAPI
from lingua_franca.parse import yes_or_no
from ovos_utils.messagebus import get_message_lang
from ovos_bus_client.util import get_message_lang
import shutil

# backwards compat imports, do not delete!
Expand Down

0 comments on commit f8cd161

Please sign in to comment.