跳至主要内容

树莓派打造淡入闹钟,让电台轻轻的叫你起床

 原文地址:https://www.hscbook.com/article/raspberrypi-alarmclock/,对作者表示感谢
16年入了一个树莓派B+版折腾了一下就放在角落里积灰了,我这天天总睡懒觉的人被冰冷的闹钟吓得激醒是非常痛苦的,某天打扫房间发现了被我打入冷宫的树莓派就顺手拿出来打造成淡入闹钟+晨起天气预报+晚间电台播放。

简介

· 早上7点定时从低音量的青苹果电台(早上电台没有节目,只有音乐)逐步提升音量轻轻的音乐声叫你起床,3分钟后语音播放今天的天气预报,一个小时后结束播放。
· 晚上10点开始低音量播放青苹果电台(现在电台播放情感节目)提醒你准备碎觉了,最后一个小时候结束播放并对你说声晚安!

准备工作

必要材料

1.男/女,聪明大脑一块
2.五指手一双
3.能上网的树莓派一个
4.音响一套

安装树莓派系统

本文采用的是树莓派官方指定系统,小白of圣手党推荐使用好方便照葫芦画瓢是吧。
这里就不教了,网上一搜一大堆的教程。
· 百度经验
· 树莓派入手体验和系统安装
· 树莓派入门之装系统

安装必要程序

Vlc 播放器

执行 sudo apt-get install vlc

Mplayer 播放器

执行 sudo apt-get install mplayer

Cron 计划任务

执行 sudo apt-get install cron

开始部署

获取代码

下载我上传的代码 Github Coding
将Morning文件夹上传到树莓派的Home文件夹里

修改文件

申请和风天气KEY 申请地址,申请百度开发者语音转换a/s key 申请地址
修改 Morning/weather.py 文件第31/65行处的“和风天气KEY”替换为你的和风天气KEY
1
2
3
4
5
6
7
8
9
10
11
12
13
14
28 ...
else:
fp = open(fn, 'w')
url_city = 'https://free-api.heweather.com/v5/citylist?search='+search+'&key=和风天气KEY'
req = urllib2.Request(url_city)
resp = urllib2.urlopen(req)
33 ...
62 ...
else:
return -1
url_weather = 'https://free-api.heweather.com/v5/'+search+'?city='+index+'&key=和风天气KEY'
req = urllib2.Request(url_weather)
resp = urllib2.urlopen(req)
68 ...
修改 Morning/weather.py 文件第82/83行处的“百度开发api_key/百度开发sec_key”替换为你的百度开发api_key/百度开发sec_key
1
2
3
4
81 ...
api_key = "百度语音api_key"
sec_key = "百度语音sec_key"
84 ...
修改 Morning/weather.py 文件第93行的城市代码为你所在的城市的代码。 城市代码列表
91 ...
def get_wat():
city_id = "CN101280601" #城市代码
city_weather = get_city_weather(city_id)
95 ...

修改其他参数

可以适当修改Morning.sh和Evening.sh文件、更换电台,设置播放时间,音量等里面的注释都写得很清楚了,这里不详细介绍了。
比如
· 修改 Morning/Morning.sh与Evening.sh 文件的“sleep 60m”可以确定播放电台多久
· 修改 Morning/Morning.sh与Evening.sh 文件的 “http://hls.qingting.fm:80/live/4576.m3u8?bitrate=64”可以更换网络电台
· 修改 –equalizer-bands=”8 3 0 -2 -1 0.5 1.5 0.5 3 1.5” 可以设定播放器的均衡器

给予执行权限

chmod 775 /home/Morning/vlc/*
chmod 775 /home/Morning/Morning.sh
chmod 775 /home/Morning/Evening.sh

添加计划任务

注意:请确定树莓派的时区是在中国,树莓派默认的时区不是中国。并确定时间是否正确
执行:
export EDITOR="/usr/bin/nano" ; crontab -e
输入:
30 07 * * * sudo /home/Morning/Morning.sh
00 22 * * * sudo /home/Morning/Evening.sh
执行时间视需求而定,比如你想早上8点叫你起床,晚上9点播放电台就修改为
00 08 * * * sudo /home/Morning/Morning.sh
00 21 * * * sudo /home/Morning/Evening.sh

END

好了,等着第二天音响里轻轻响起的音乐开始美好的一天吧,有什么问题可以在下面留言

Popular posts from 产品随想的博客

Steve Jobs: `There's Sanity Returning', 1998

Nobody can doubt the charisma of Steven P. Jobs. The interim CEO of Apple Computer Inc., who returned to the company last July after his ignominious 1985 ouster, has brought back his legendary vision, impatience, and infectious passion for the Macintosh. Jobs spoke to Business Week Correspondent Andy Reinhardt in Apple's stark, fourth-floor boardroom, just after the company rolled out its new software strategy on May 11. Note: This is an extended, online-only version of the Q&A that appears in the May 25, 1998, issue of Business Week. Q: Now that you've introduced the new, bold-looking iMac, are you going to do some radically different products? A: There's a lot of talk about such things -- about handhelds, set-top boxes. A lot of computer companies have been searching for a consumer product. My view is that the personal computer has been the most successful consumer product of the last 10 years. What we have to do, what the industry stopp...

Notes for the New Year

Notes for the New Year by Sam Altman 1/4/2017 Happy 2017! As a kid, I just sort of took for granted that stuff got better every year—TVs got bigger and then thinner, cars got a little faster, and computers got unbelievably better on an exponential curve. As an adult, I realized that the future is not guaranteed to be better. The default is that things stay the same (or get worse because we continue to create new problems and occasionally get in wars). The world only gets better if committed people with strong visions about the future work hard to make it better. It’s easy to get caught up in the moving sidewalk of a career and end up deeply involved in something that does not maximize your potential. It’s never too late to change, and it’s always good to be thoughtful about the path you’re on and how to best use your time. I made some notes before my brother Jack interviewed me for How to Build the Future , where I mostly talked about how ambitious young people should thi...

Oral History Interview with Steve Jobs, 1995

  Excerpts from an Oral History Interview with Steve Jobs Founder, NeXT Computer. Interviewer: Daniel Morrow, Executive Director, The Computerworld Smithsonian Awards Program Date of Interview: 20 April 1995 Location: NeXT Computer Transcript Editor: Thomas J. Campanella, Computerworld Smithsonian Awards Learning to Use Tools The Importance of Education The Role of Computers in Education The Costs of Education - Alternatives The Apple Computer Company The Growth of Apple Computer The Kids Can't Wait The NeXT Computer Company NeXT Computer Software The Internet Pixar Software New Possibilities Advice for Future Entrepreneurs The Responsibilities of Power Learning to Use Tools Daniel Morrow (DM) : Steve, I'd like to begin with some biographical information. Tell us about yourself. Steve Jobs (SJ) : I was born in San Francisco, California, USA, planet Earth, February 24, 1955. I can go into a lot of details about my yo...

利用Rhino+GH+AI的数据可视化表现

原文来自 韩世麟博客 ,表示感谢,感谢作者可可 使用软件:Rhinoceros, Grasshopper, Illustrator 编者按: 可可 这次又带来神级教程,可以说完美的解决了一大类图解的绘制思路问题。我经常被问到类似文中的数据可视化图解“是怎么画的”这类问题,无奈对于数据处理方面,我知之甚少。相信今天的这一篇文章能够为大家解惑。 作者简介 张可天 张可天是2015年毕业于天津大学的建筑学硕士。目前就职于天津市设计院。他专长建筑方案设计及表现,基本功扎实,而且他也一直乐于分享他总结到的技巧,曾经在人人网上接连发表过多篇图文教程: 《可可这样画》 系列。同时他也是专筑网 《SketchUp极速出图八讲》 的主讲人。 这是一篇我在知乎的回答 (点击这里查看张可天的知乎答案) ,题主提出的参考原图如下,希望能够得知这张图的画法。 我尝试用Rhino+Grasshopper画图并导入AI修饰,步骤如下: 1.取得数据 样例中的图应该是有数据来源的,可能是作者调研或文献摘录的。我并没有这些数据,所以我把原图中的数据大概加估计地逆向回来。数据的存在形式有很多种,我使用了比较常见的一种,将数据放在一张EXCEL表格的两个SHEET中,如下图。 Sheet1是一张映射关系图,是样例图中从右上方到左下方的那些个映射曲线数据。excel中,横轴是“人口分布(Population Distribution)”中的各类人,纵轴是“元素时间表(Element Timeline)”中的那些“元素(Element)”,“0”代表着没有映射关系,“1”代表著有映射关系。 Sheet2是一张时间数据图,是样例图中右下的那张大表格的数据。excel中,横轴是样例图的“时间点”,纵轴是“元素(Element)”,其中的数据根据原图中的意思,应该是某个“元素(Element)”在“工作日/休息日(Workday/Weekend)”时,特定的“时间点”上所接待或容纳的人数。我并没有看出来样例图中该数据的单位,所以我臆测了一下。我以垂直方向一格代表“10人”为单位,读取了这些数据,得到上表。 2.导入Rhino 我使用Grasshopper中的Bumble Bee将Excel数据导进来,这个插件是我能够找到的导入Excel表格效率最高的一个插件...

Steve Jobs Talks about Creativity

“Creativity is just connecting things,” Jobs told   Wired   magazine. “When you ask creative people how they did something, they feel a little guilty because they didn’t really do it, they just saw something. It seemed obvious to them after a while. That’s because they were able to connect experiences they’ve had and synthesize new things. And the reason they were able to do that was that they’ve had more experiences or they have thought more about their experiences than other people. . . . Unfortunately, that’s too rare a commodity. A lot of people in our industry haven’t had very diverse experiences. So they don’t have enough dots to connect, and they end up with very linear solutions without a broad perspective on the problem. The broader one’s understanding of the human experience, the better design we will have.”

ISSUU使用指南--木喵

作者: 木喵   出处: Wonderworks 问:issuu是什么? 答:Issuu是国外的一个在线文档共享网站,它是你的PDF文档发布专家。它类似于我们熟悉的youtube,但它共享的是文档、杂志之类的文本。 简而言之、同志们想看国外的各种杂志? 想找国外的汇报文本么? 想借鉴国外学生的作品集么? 那么你就要用到它啦~ 今天主要和大家讲两个方面 一、如何在pc端使用和下载issuu上的pdf文档 首先我们打开issuu的网址 https://issuu.com/ 我们可以很清楚的看到网页上呢都是国外的杂志以及一些作者自己制作的pdf文档 首先我们点击右上角的 sign up  然后填写相关信息注册一个账户: 注册完成之后我们就可以搜索我们想要找的资料: 比如说,我想找一些分析图的资料,我们就搜索: architecture diagram 然后我们就可以看到相关的文档了: 点击你所选择的文档, 好了问题来了: sorry,this publication is not available 这个时候!就需要在用pc端的我们做一件必不可少的事: 翻墙 然后我们就能将页面刷新粗来了 好、接下来是非常有建设性意义的一步 怎样把我们网页上的文件 下载下来 呢? 截图? no~no~no~ 接下来,让木喵告诉你怎么下载: 首先你需要复制上面的网址 然后将 https://wenfan.hk/issuu/index_link.php 在另一个网址中打开 将你之前复制的pdf的网址粘贴在下面的对话框中 点击 I‘m not a robot 再点击 get it 然后会出现一堆网址代码 我们 全选 打开你的迅雷点击 新建 将你之前的复制粘贴到下载链接里 然后呢~我们就全都下载成功啦~ 然后我们回到之前的网页向下看 我们可以看到有上传文档的作者(记得要关注哟) 然后还有 info   share   stack   ❤ 如果...

Rhino_GH从入门到精通听课笔记_二

一. 基础操作   1. Rhino F6精确更改相机视野   2. 中键和左菜单栏弹出时间都是可以自己设置缩短的 二. 软件技巧   1. GH搭配生成楼梯,柱子,栏杆   2. SU\3DS\OBJ 均可被Rhino识别   3. 已命名工作位置很有用,和和已命名是图标是不一样的   4. Rhino等轴测做法          显示——投影——改为平行          旋转改为0/360          视图——等角视图 三. 奇技淫巧   1. 善用微信搜索,比如“地形制作”,第三讲前半部分讲解利用高程点制作地形   2. Rhino转折剖制作方法,用面split模型,即模型被切成两个,类似于佐罗刀   3. 转折剖模型制作时间很久,工作量比较大 四. Rhino命令   1. worksession  链接文件进来,以一个图层显示,类似于SU里面的另存再载入的操作,可       以节省运算量,比ctrl+c ctrl+v快   2. ctrl+w  局部放大   3. hatch  嵌面

世界需要什么样的智能系统

原文: - By 道哥 - Link:https://archive.ph/h0nNj  笔记: - 人工智能,不应该是一个产业,应该是各个产业,都要有智能; - 智能:感知+行动 (目前很多视觉、语音的识别,停留在感知层面) - 智能技术角度看, 自动驾驶与智能音箱是两个完整的从“感知”到“行动”的闭环     - 对话机器人被成为人工智能界的圣杯 - 构建智能时代:     - 飞行员:各个企业中,智能部门的员工     - 航道:基础设施提供商,比如运营商、云计算厂商     - 机场:最后真正的商业模式,类似苹果的App Store,给机器智能系统提供服务 - 机器与机器的协同交互,价值巨大(以往很看重的是:机器与人的交互) - 数据、训练在内部;一旦进行外部的机器交流,默认为“不信任”模式 - 云计算厂商可能会被智能厂商管道化,就跟运营商被互联网内容提供商管道化一样(因为:云计算和大数据都不是智能)

CAD 天正与 AI 工作流

基本步骤   1. 天正导出 T3 .dwg 文件,尽量在2007版本   2. AI 打开,打开时候可以选择比例,因为 AI 画布是基于真实尺度   3. AI 打开 .dwg 后,更改画布到所需要的大小   4. 之后用 PS 打开 AI 文件,可以维持想要的大小和比例   5. 而且 AI 可以读取天正的图层 课外了解   1. ETH 风格平面图   2. 日本创新性的停车方式   3. AI中的实时上色功能去了解