[assistant.picovoice] Leverage upstream _on_mute_changed.

The plugin should leverage `AssistantPlugin._on_mute_changed` to handle
the boilerplate state managent on mute/unmute actions instead of
re-implementing the same logic.
This commit is contained in:
Fabio Manganiello 2024-04-13 21:00:30 +02:00
parent 2c197c275e
commit a345b12244

View file

@ -2,7 +2,6 @@ import os
from typing import Optional, Sequence from typing import Optional, Sequence
from platypush.context import get_plugin from platypush.context import get_plugin
from platypush.message.event.assistant import MicMutedEvent, MicUnmutedEvent
from platypush.plugins import RunnablePlugin, action from platypush.plugins import RunnablePlugin, action
from platypush.plugins.assistant import AssistantPlugin from platypush.plugins.assistant import AssistantPlugin
from platypush.plugins.tts.picovoice import TtsPicovoicePlugin from platypush.plugins.tts.picovoice import TtsPicovoicePlugin
@ -239,11 +238,10 @@ class AssistantPicovoicePlugin(AssistantPlugin, RunnablePlugin):
:param muted: Set to True or False. :param muted: Set to True or False.
""" """
self._is_muted = muted
if self._assistant: if self._assistant:
self._assistant.set_mic_mute(muted) self._assistant.set_mic_mute(muted)
self._send_event(MicMutedEvent if muted else MicUnmutedEvent) super()._on_mute_changed(muted)
@action @action
def toggle_mute(self, *_, **__): def toggle_mute(self, *_, **__):