Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ speechrecognition~=3.10.0
urllib3~=2.2.2
wheel~=0.41.2
wikipedia~=1.4.0
feedparser~=6.0.11
sgmllib3k~=1.0.0

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
3 changes: 3 additions & 0 deletions src/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def execute_query(self, query: str) -> None:
else:
print("Scroll command not recognized")

elif "news" in query:
commands.fetch_news(self.__voice_interface)

else:
self.__voice_interface.speak("could not interpret the query")

Expand Down
24 changes: 24 additions & 0 deletions src/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from datetime import datetime
from subprocess import CalledProcessError, TimeoutExpired

import feedparser
import googlesearch
import pyautogui as pag
import pygetwindow
Expand Down Expand Up @@ -293,3 +294,26 @@ def simple_scroll(direction: str) -> None:
pag.press(keys=direction, presses=25)
else:
print("Invalid direction")


def fetch_news(vi: VoiceInterface) -> None:
"""News Reporter fetches headlines from news.google.com rss feed and reads top 5 headlines"""

feed_url = "https://news.google.com/rss?hl=en-IN&gl=IN&ceid=IN:en"
max_fetched_headlines = 5

vi.speak("Fetching news from servers.")

feed = feedparser.parse(feed_url)
if feed.status == 200:
headlines_list = []
for entry in feed.entries[:max_fetched_headlines]:
headlines_list.append((entry.title).split(" -")[0])

vi.speak("Here are some recent news headlines.")

for headline in headlines_list:
vi.speak(headline)

else:
vi.speak("Failed to fetch the news.")