May 17, 2026, 11:40 PM
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import pyttsx3
|
||||
import requests
|
||||
|
||||
engine = pyttsx3.init('sapi5')
|
||||
voices = engine.getProperty('voices')
|
||||
engine.setProperty('voice', voices[0].id)
|
||||
|
||||
def speak(audio):
|
||||
engine.say(audio)
|
||||
engine.runAndWait()
|
||||
|
||||
def trndnews():
|
||||
url = " http://newsapi.org/v2/top-headlines?country=us&apiKey=GET_YOUR_OWN"
|
||||
page = requests.get(url).json()
|
||||
article = page["articles"]
|
||||
results = []
|
||||
for ar in article:
|
||||
results.append(ar["title"])
|
||||
for i in range(len(results)):
|
||||
print(i + 1, results[i])
|
||||
speak(results)
|
||||
|
||||
trndnews()
|
||||
|
||||
''' Run The Script To Get The Top Headlines From USA'''
|
||||
Reference in New Issue
Block a user