forked from zahariev-webbersof/python-mini-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeaking_news_bot.py
More file actions
27 lines (24 loc) · 823 Bytes
/
speaking_news_bot.py
File metadata and controls
27 lines (24 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def speak(str):
from win32com.client import Dispatch
speak = Dispatch("SAPI.SpVoice")
speak.Speak(str)
if __name__ == '__main__':
import requests
import json
query_params = {
"source": "bbc-news",
"sortBy": "top",
"apiKey": "4dbc17e007ab436fb66416009dfb59a8"
}
main_url = " https://newsapi.org/v1/articles"
res = requests.get(main_url, params=query_params)
load = json.loads(res.text)
speak('Here you listen top BBC news from SoftUni Fundamentals Team. Lets began')
speak('first news')
for i in range(4):
print(load['articles'][i]['title'])
speak(load['articles'][i]['title'])
if i < 3:
speak('next news')
else:
speak('This was top 4 BBC news from SoftUni Fundamentals Team.See you Soon')