Added tts.stop method.

This commit is contained in:
Fabio Manganiello 2024-06-02 00:50:25 +02:00
parent fcae7aa3ad
commit f356fcd844
3 changed files with 22 additions and 12 deletions

View file

@ -1,4 +1,4 @@
from abc import ABC, abstractmethod
from abc import ABC
from dataclasses import asdict, dataclass
from enum import Enum
import os
@ -111,19 +111,17 @@ class AssistantPlugin(Plugin, AssistantEntityManager, ABC):
alert_state=self._cur_alert_type.value if self._cur_alert_type else None,
)
@abstractmethod
def start_conversation(self, *_, **__):
"""
Programmatically starts a conversation.
"""
raise NotImplementedError
@abstractmethod
@action
def stop_conversation(self, *_, **__):
"""
Programmatically stops a conversation.
"""
raise NotImplementedError
self._stop_conversation()
def _stop_conversation(self, *_, **__):
tts = self._get_tts_plugin()
if tts:
tts.stop()
@action
def pause_detection(self, *_, **__):

View file

@ -181,8 +181,7 @@ class AssistantGooglePlugin(AssistantPlugin, RunnablePlugin):
if self.assistant:
self.assistant.start_conversation()
@action
def stop_conversation(self, *_, **__):
def _stop_conversation(self, *_, **__):
"""
Programmatically stop a running conversation with the assistant
"""

View file

@ -55,5 +55,18 @@ class TtsPlugin(Plugin):
self._playback(url, **player_args)
@action
def stop(self):
"""
Stop the playback.
"""
try:
audio = get_plugin('sound')
except Exception:
return
if audio:
audio.stop_playback()
# vim:sw=4:ts=4:et: