我已经编写了这个小的Python脚本来收听Raspberry Pi上的BBC RSS热门故事提要
首先,因为我对3.5毫米插孔有问题(没有声音,所以我进入了
sudo raspi-config
然后在“高级选项”>“音频中,我选择了“ Force 3.5 mm('耳机')插孔”]
(这总是对我有用)
因此插孔配置不受影响,让我们检查一下脚本:
# morning.py
import feedparser # To scrape the BBC Feed
import talkey # The TTS service I'll be using
d = feedparser.parse("http://feeds.bbci.co.uk/news/rss.xml")
tts = talkey.Talkey(
engine_preference=['espeak'],
espeak={
'deafults': {
'words_per_minute': 100,
'variant': 'f4',
}
}
)
for entry in d.entries:
tts.say(entry.title + ":" + entry.summary)
我希望脚本在特定时间运行(上午),所以我使用了Cron-Linux的任务管理器。这是我输入的
crontab -e
0 8 * * * sudo python morning.py >/dev/null 2>&1 # inside crontab
((Morning.py脚本位于'pi'目录中。)
但是由于某种原因该脚本将在指定的时间不运行。
(尽管没有Cron,它运行得很好。)
您可能需要使用以下命令来初始化crontab临时外壳: