-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrolling app window feature added #49
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import re | ||
from datetime import datetime | ||
|
||
import threading | ||
import Support | ||
from VoiceInterface import VoiceInterface | ||
|
||
LISTENING_ERROR = "Say that again please..." | ||
|
||
|
||
|
||
class Assistant: | ||
def __init__(self): | ||
"""Creates an Assistant instance consisting of an VoiceInterface instance""" | ||
self.__voiceInterface = VoiceInterface() | ||
|
||
|
||
|
||
def wish_user(self): | ||
"""Wishes user based on the hour of the day""" | ||
|
@@ -40,15 +43,17 @@ def listen_for_query(self) -> str: | |
|
||
|
||
def execute_query(self, query: str) -> None: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundant blank line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed the lines |
||
"""Processes the query string and runs the corresponding tasks | ||
|
||
Args: | ||
query (str): the query string obtained from speech input | ||
""" | ||
# if any( text in query for text in ['exit', 'quit', 'close'] ): | ||
# return | ||
|
||
if 'what can you do' in query: | ||
if query is None: | ||
print("No query detected. Please provide an input.") | ||
elif 'what can you do' in query: | ||
Support.explain_features(self.__voiceInterface) | ||
|
||
elif re.match(r'(what|all|list).*apps.*open', query): | ||
|
@@ -78,6 +83,34 @@ def execute_query(self, query: str) -> None: | |
|
||
elif any(text in query for text in ["the time", "time please"]): | ||
Support.tell_time(self.__voiceInterface) | ||
|
||
elif 'scroll' in query: | ||
if re.search(r'start scrolling (up|down|left|right|top|bottom)', query): | ||
direction = re.findall(r'start scrolling (up|down|left|right|top|bottom)', query)[0] | ||
scroll_thread,stop_scroll_event=Support.setup_scrolling() | ||
if scroll_thread is None: # Only start if not already scrolling | ||
Support.start_scrolling(direction) | ||
|
||
elif 'stop scrolling' in query: | ||
scroll_thread,stop_scroll_event=Support.setup_scrolling() | ||
if scroll_thread is not None: | ||
Support.stop_scrolling() | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary gap between two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed the blank lines. I also went the through the |
||
|
||
|
||
elif re.search(r'scroll to (up|down|left|right|top|bottom)', query): | ||
match = re.search(r'scroll to (up|down|left|right|top|bottom)', query) | ||
direction = match.group(1) | ||
Support.scroll_to(direction) | ||
elif re.search(r'scroll (up|down|left|right)', query): | ||
match = re.search(r'scroll (up|down|left|right)', query) | ||
direction = match.group(1) | ||
Support.simple_scroll(direction) | ||
|
||
|
||
else: | ||
print("Scroll command not recognized") | ||
|
||
else: | ||
self.__voiceInterface.speak("could not interpret the query") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two line gap is enough...no need for having three blank lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept only two blank lines.