READING NEWSPAPER---IN PYTHON --DAY 4

 """
# pip install pywin32


def speak(str):
from win32com.client import Dispatch

speak=Dispatch("SAPI.SpVoice")

# speak.Speak(" ami akhon fan er haoaye boste chai")
speak.Speak(str)
if __name__=='__main__':
speak("ram narayana ")


"""

"""
# Akhbaar padhke sunaao
# Attempt it yourself and watch the series for solution and shoutouts for this lecture!
def speak(str):
from win32com.client import Dispatch
speak=Dispatch("SAPI.spVoice")
speak.Speak(str)

if __name__ == '__main__':
import requests
import json
url = ('https://newsapi.org/v2/top-headlines?'
'sources=bbc-sport&'
'apiKey=49e391e7066c4158937096fb5e55fb5d')##my api key=7b1eae74031a4d31a9b38e5e45e6b9ee

response = requests.get(url)
text = response.text
my_json = json.loads(text)
for i in range(0, 11):
speak(my_json['articles'][i]['title'])
"""

# Akhbaar padhke sunaao
import requests
import json

def speak(str):
from win32com.client import Dispatch
speak = Dispatch("SAPI.SpVoice")
speak.Speak(str)

if __name__ == '__main__':
speak("News for today.. Lets begin")
url = "https://newsapi.org/v2/top-headlines?sources=the-times-of-india&apiKey=d093053d72bc40248998159804e0e67d"
news = requests.get(url).text
news_dict = json.loads(news)
arts = news_dict['articles']
for article in arts:
speak(article['title'])
print(article['title'])
speak("Moving on to the next news..Listen Carefully")

speak("Thanks for listening...")



Comments

Popular posts from this blog

java chapter11 practice question on abstruct class and interfaces

DAY 12 -AZURE DP900(Microsoft Azure Data Fundamentals: Explore non-relational data in Azure)

java exercise4