def __init__(self, bus=None, gui=None): self.bus = bus or get_mycroft_bus() self.bus.on("better_cps.query.response", self.handle_cps_response) self.bus.on("better_cps.status.update", self.handle_cps_status_change) self.gui = gui or GUIInterface("better-cps", bus=self.bus) self.register_gui_handlers()
def __init__(self, bus=None): self.bus = bus or get_mycroft_bus() self.bus.on("play:query.response", self.handle_cps_response) self.query_replies = {} self.query_extensions = {} self.waiting = False self.start_ts = 0
def __init__(self, bus=None, min_timeout=1, max_timeout=5, allow_extensions=True, audio_service=None, gui=None, backwards_compatibility=True, media_fallback=True): """ Arguments: bus (MessageBus): mycroft messagebus connection min_timeout (float): minimum time to wait for skill replies, after this time, if at least 1 result was found, selection is triggered max_timeout (float): maximum time to wait for skill replies, after this time, regardless of number of results, selection is triggered allow_extensions (bool): if True, allow skills to request more time, extend min_timeout for specific queries up to max_timeout backwards_compatibility (bool): if True emits the regular mycroft-core bus messages to get results from "old style" skills media_fallback (bool): if no results, perform a second query with CPSMatchType.GENERIC """ self.bus = bus or get_mycroft_bus() self.audio_service = audio_service or AudioServiceInterface(self.bus) self.gui = gui or GUIInterface("better-cps", bus=self.bus) self.min_timeout = min_timeout self.max_timeout = max_timeout self.allow_extensions = allow_extensions self.media_fallback = media_fallback if backwards_compatibility: self.old_cps = CommonPlayInterface(self.bus) else: self.old_cps = None self.query_replies = {} self.query_timeouts = {} self.waiting = False self.search_start = 0 self._search_results = [] self.playback_status = CPSTrackStatus.END_OF_MEDIA self.active_backend = None # re-uses CPSTrackStatus.PLAYING_XXX self.active_skill = None # skill_id currently handling playback self.playback_data = { "playing": None, "playlist": [], "disambiguation": [] } self.bus.on("better_cps.query.response", self.handle_cps_response) self.bus.on("better_cps.status.update", self.handle_cps_status_change) self.register_gui_handlers()
def __init__(self, bus=None, layers=None): layers = layers or [] self.bus = bus or get_mycroft_bus() # make intent levels for N layers self.layers = layers self.current_layer = 0 self.activate_layer(0) self.named_layers = {}
def __init__(self, bus=None, color=None): super().__init__() self.bus = bus or get_mycroft_bus() self.api = Mark1EnclosureAPI(self.bus) self.right = RightEye(self.bus) self.left = LeftEye(self.bus) self.color = Color() if color: self.change_color(color) else: self.sync_color()
def __init__(self, pixel_range, bus=None, color=None): super().__init__() self.bus = bus or get_mycroft_bus() self.api = Mark1EnclosureAPI(self.bus) for idx in range(pixel_range[0], pixel_range[1]): pixel = EyePixel(idx, self.api) self.append(pixel) self.color = Color() if color: self.change_color(color) else: self.sync_color()
def __init__(self, bus=None, config=None, name="dummy window"): self.name = name self.bus = bus or get_mycroft_bus() self.config = config self.index = 0 self._is_windowing = False self.pictures = [] self.width = 1600 self.height = 900 self.fullscreen = False self._window_start_callback = None self.default_picture = "https://raw.githubusercontent.com/OpenVoiceOS/ovos_assets/master/Logo/ovos-logo-512.png"
def __init__(self, grid=None, bus=None): self.bus = bus or get_mycroft_bus() self._api = Mark1EnclosureAPI(self.bus) self.grid = [] for x in range(8): self.grid.append([]) for y in range(32): self.grid[x].append(0) if self.encoded: self.grid = self.decode(self.encoded).grid elif self.str_grid is not None: self.grid = FaceplateGrid(bus=self.bus)\ .from_string(self.str_grid).grid elif grid is not None: self.grid = grid
def __init__(self, bus=None): self.bus = bus or get_mycroft_bus() self.config = read_mycroft_config().get("common_windows") or {} self.service_lock = Lock() self.default = None self.services = [] self.current = None raise NotImplementedError self.services = load_services(self.config, self.bus) # Register end of picture callback for s in self.services: s.set_window_start_callback(self.on_display_start) # Find default backend default_name = self.config.get('default-backend', '') LOG.info('Finding default backend...') for s in self.services: if s.name == default_name: self.default = s LOG.info('Found ' + self.default.name) break else: self.default = None LOG.info('no default found') # Setup event handlers self.bus.on('ovos.ccanvas.window', self._display) self.bus.on('ovos.ccanvas.queue', self._queue) self.bus.on('ovos.ccanvas.stop', self._stop) self.bus.on('ovos.ccanvas.clear', self._clear) self.bus.on('ovos.ccanvas.close', self._close) self.bus.on('ovos.ccanvas.reset', self._reset) self.bus.on('ovos.ccanvas.next', self._next) self.bus.on('ovos.ccanvas.prev', self._prev) self.bus.on('ovos.ccanvas.height', self._set_height) self.bus.on('ovos.ccanvas.width', self._set_width) self.bus.on('ovos.ccanvas.fullscreen', self._set_fullscreen) self.bus.on('ovos.ccanvas.picture_info', self._picture_info) self.bus.on('ovos.ccanvas.list_backends', self._list_backends)
self.direction = "d" elif bottom_collision: self.direction = "u" # bounce the "emitter" up and down if self.direction == "u": self.line_up() else: self.line_down() # create particles period = self.period or random.randint(0, 20) if self.num_particles < 1 or self.counter >= period: self.grid[self.line + 1][2] = 1 self.counter = 0 # animate particles self.scroll_particles() self.counter += 1 if __name__ == "__main__": from ovos_utils.messagebus import get_mycroft_bus from time import sleep bus = get_mycroft_bus("192.168.1.70") for faceplate in ParticleBox(bus=bus): faceplate.display(invert=False) sleep(0.5)
def bind(cls, bus=None): cls.bus = bus or get_mycroft_bus()
def __init__(self, bus=None): self.bus = bus or get_mycroft_bus()
from ovos_utils.messagebus import get_mycroft_bus, listen_for_message from ovos_utils import wait_for_exit_signal from ovos_utils.lang.translate import say_in_language # from ovos_utils.lang.translate import translate_to_mp3 # from ovos_utils.sound import play_mp3 bus_ip = "0.0.0.0" # enter a remote ip here, remember bus is unencrypted! careful with opening firewalls bus = get_mycroft_bus(host=bus_ip) TARGET_LANG = "pt" def translate(message): utterance = message.data["utterance"] say_in_language(utterance, lang=TARGET_LANG) # will play .mp3 directly # if you need more control # path = translate_to_mp3(utterance, lang=TARGET_LANG) # play_mp3(path, cmd="play %1") # using sox listen_for_message("speak", translate, bus=bus) wait_for_exit_signal() # wait for ctrl+c bus.remove_all_listeners("speak") bus.close()
def __init__(self, skill_id, bus=None): self.bus = bus or get_mycroft_bus() self.skill_id = skill_id