forked from platypush/platypush
Added tts.stop
method.
This commit is contained in:
parent
fcae7aa3ad
commit
f356fcd844
3 changed files with 22 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC
|
||||||
from dataclasses import asdict, dataclass
|
from dataclasses import asdict, dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import os
|
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,
|
alert_state=self._cur_alert_type.value if self._cur_alert_type else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@abstractmethod
|
@action
|
||||||
def start_conversation(self, *_, **__):
|
|
||||||
"""
|
|
||||||
Programmatically starts a conversation.
|
|
||||||
"""
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def stop_conversation(self, *_, **__):
|
def stop_conversation(self, *_, **__):
|
||||||
"""
|
"""
|
||||||
Programmatically stops a conversation.
|
Programmatically stops a conversation.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
self._stop_conversation()
|
||||||
|
|
||||||
|
def _stop_conversation(self, *_, **__):
|
||||||
|
tts = self._get_tts_plugin()
|
||||||
|
if tts:
|
||||||
|
tts.stop()
|
||||||
|
|
||||||
@action
|
@action
|
||||||
def pause_detection(self, *_, **__):
|
def pause_detection(self, *_, **__):
|
||||||
|
|
|
@ -181,8 +181,7 @@ class AssistantGooglePlugin(AssistantPlugin, RunnablePlugin):
|
||||||
if self.assistant:
|
if self.assistant:
|
||||||
self.assistant.start_conversation()
|
self.assistant.start_conversation()
|
||||||
|
|
||||||
@action
|
def _stop_conversation(self, *_, **__):
|
||||||
def stop_conversation(self, *_, **__):
|
|
||||||
"""
|
"""
|
||||||
Programmatically stop a running conversation with the assistant
|
Programmatically stop a running conversation with the assistant
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -55,5 +55,18 @@ class TtsPlugin(Plugin):
|
||||||
|
|
||||||
self._playback(url, **player_args)
|
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:
|
# vim:sw=4:ts=4:et:
|
||||||
|
|
Loading…
Reference in a new issue