-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
166 changed files
with
16,018 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dingdang.hahack.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# -*- coding: utf-8-*- | ||
|
||
import os | ||
import subprocess | ||
import time | ||
import sys | ||
|
||
WORDS = [u"PAIZHAO", u"ZHAOPIAN"] | ||
SLUG = "camera" | ||
|
||
|
||
def handle(text, mic, profile, wxbot=None): | ||
""" | ||
Reports the current time based on the user's timezone. | ||
Arguments: | ||
text -- user-input, typically transcribed speech | ||
mic -- used to interact with the user (for both input and output) | ||
profile -- contains information related to the user (e.g., phone | ||
number) | ||
wxbot -- wechat bot instance | ||
""" | ||
sys.path.append(mic.dingdangpath.LIB_PATH) | ||
from app_utils import sendToUser | ||
|
||
quality = 100 | ||
count_down = 3 | ||
dest_path = os.path.expanduser('~/pictures') | ||
vertical_flip = False | ||
horizontal_flip = False | ||
send_to_user = True | ||
sound = True | ||
usb_camera = False | ||
# read config | ||
if profile[SLUG] and 'enable' in profile[SLUG] and \ | ||
profile[SLUG]['enable']: | ||
if 'count_down' in profile[SLUG] and \ | ||
profile[SLUG]['count_down'] > 0: | ||
count_down = profile[SLUG]['count_down'] | ||
if 'quality' in profile[SLUG] and \ | ||
profile[SLUG]['quality'] > 0: | ||
quality = profile[SLUG]['quality'] | ||
if 'dest_path' in profile[SLUG] and \ | ||
profile[SLUG]['dest_path'] != '': | ||
dest_path = profile[SLUG]['dest_path'] | ||
if 'vertical_flip' in profile[SLUG] and \ | ||
profile[SLUG]['vertical_flip']: | ||
vertical_flip = True | ||
if 'horizontal_flip' in profile[SLUG] and \ | ||
profile[SLUG]['horizontal_flip']: | ||
horizontal_flip = True | ||
if 'send_to_user' in profile[SLUG] and \ | ||
not profile[SLUG]['send_to_user']: | ||
send_to_user = False | ||
if 'sound' in profile[SLUG] and \ | ||
not profile[SLUG]['sound']: | ||
sound = False | ||
if 'usb_camera' in profile[SLUG] and \ | ||
profile[SLUG]['usb_camera']: | ||
usb_camera = True | ||
if any(word in text for word in [u"安静", u"偷偷", u"悄悄"]): | ||
sound = False | ||
try: | ||
if not os.path.exists(dest_path): | ||
os.makedirs(dest_path) | ||
except Exception: | ||
mic.say(u"抱歉,照片目录创建失败") | ||
return | ||
dest_file = os.path.join(dest_path, "%s.jpg" % time.time()) | ||
if usb_camera: | ||
command = "fswebcam --no-banner -r 1024x765 -q " | ||
if vertical_flip: | ||
command = command+' -s v ' | ||
if horizontal_flip: | ||
command = command+'-s h ' | ||
command = command+dest_file | ||
else: | ||
command = ['raspistill', '-o', dest_file, '-q', str(quality)] | ||
if count_down > 0 and sound: | ||
command.extend(['-t', str(count_down*1000)]) | ||
if vertical_flip: | ||
command.append('-vf') | ||
if horizontal_flip: | ||
command.append('-hf') | ||
if sound and count_down > 0: | ||
mic.say(u"收到,%d秒后启动拍照" % (count_down)) | ||
if usb_camera: time.sleep(count_down) | ||
|
||
process = subprocess.Popen(command, shell=usb_camera) | ||
res = process.wait() | ||
if res != 0: | ||
if sound: | ||
mic.say(u"拍照失败,请检查相机是否连接正确") | ||
return | ||
if sound: | ||
mic.play(mic.dingdangpath.data('audio', 'camera.wav')) | ||
# send to user | ||
if send_to_user: | ||
target = '邮箱' | ||
if wxbot is not None and wxbot.my_account != {} and \ | ||
('prefers_email' not in profile or | ||
not profile['prefers_email']): | ||
target = '微信' | ||
if sound: | ||
mic.say(u'拍照成功!正在发送照片到您的%s' % target) | ||
if sendToUser(profile, wxbot, u"这是刚刚为您拍摄的照片", "", [dest_file], []): | ||
if sound: | ||
mic.say(u'发送成功') | ||
else: | ||
if sound: | ||
mic.say(u'发送失败了') | ||
else: | ||
mic.say(u"请先在配置文件中开启相机拍照功能") | ||
|
||
|
||
def isValid(text): | ||
""" | ||
Returns True if input is related to the time. | ||
Arguments: | ||
text -- user-input, typically transcribed speech | ||
""" | ||
return any(word in text for word in ["拍照", "拍张照"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# The MIT License (MIT) | ||
|
||
*Copyright (c) 2017 Weizhou Pan(潘伟洲)* | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
dingdang-robot's main project skeleton is modified from Jasper project, under | ||
MIT License. Their copyrights are also included. | ||
|
||
*Copyright (c) 2014-2015 Charles Marsh, Shubhro Saha & Jan Holthuis* | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,198 @@ | ||
# honk-dingdang | ||
叮当——中文语音对话机器人 | ||
============= | ||
|
||
[](https://github.com/dingdang-robot/dingdang-robot/releases) | ||
[](https://travis-ci.org/dingdang-robot/dingdang-robot) | ||
[](https://github.com/dingdang-robot/dingdang-robot/issues) | ||
[](https://github.com/dingdang-robot/dingdang-robot/pulls) | ||
[](https://github.com/dingdang-robot/dingdang-robot/blob/master/LICENSE) | ||
[](http://onmw7y6f4.bkt.clouddn.com/dingdang-group.png) | ||
|
||
> 注意:本项目已不再维护。请关注 [wukong-robot](https://github.com/wzpan/wukong-robot) 项目。目的是提供一个更快、更稳定、更容易搭建的机器人,同时兼容dingdang-robot的插件机制。 | ||
叮当是一款可以工作在 Raspberry Pi 上的开源中文语音对话机器人/智能音箱项目,目的是让中国的Hacker们也能快速打造个性化的智能音箱。 | ||
|
||
<h1 align="center"> | ||
<img width="250" src="http://onmw7y6f4.bkt.clouddn.com/dingdang-logo.png" alt="dingdang"> | ||
</h1> | ||
|
||
<div class="video"> | ||
<div class="MIAOPAI_player" style='width:600px;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select:none;user-select:none;' > | ||
</div> | ||
</div> | ||
|
||
<div id="demo_placeholder"> | ||
</div> | ||
|
||
## Table of Contents | ||
|
||
* [特性](#特性) | ||
* [Demo](#demo) | ||
* [硬件要求](#硬件要求) | ||
* [安装](#安装) | ||
* [升级](#升级) | ||
* [配置](#配置) | ||
* [运行](#运行) | ||
* [退出](#退出) | ||
* [插件](#插件) | ||
* [贡献](#贡献) | ||
* [联系](#联系) | ||
* [感谢](#感谢) | ||
* [FAQ](#faq) | ||
* [免责声明](#免责声明) | ||
|
||
## 特性 | ||
|
||
 | ||
|
||
叮当包括以下诸多特性: | ||
|
||
* 模块化。功能插件、语音识别、语音合成、对话机器人都做到了高度模块化,第三方插件单独维护,方便继承和开发自己的插件。 | ||
* 微信接入。支持接入微信,并通过微信远程操控自己家中的设备。 | ||
* 中文支持。集成百度、科大讯飞、阿里、谷歌等多家中文语音识别和语音合成技术,且可以继续扩展。 | ||
* 对话机器人支持。支持接入图灵机器人、Emotibot,未来还将支持接入更多机器人。 | ||
* 全局监听,离线唤醒。支持无接触地离线语音指令唤醒。 | ||
* 灵活可配置。支持定制机器人名字,支持选择语音识别和合成的插件。 | ||
* 智能家居。集成 HomeAssistant 插件,支持语音控制智能家电。 | ||
|
||
叮当的工作模式: | ||
|
||
 | ||
|
||
叮当被唤醒后,用户的语音指令先经过在线 STT 引擎进行 ASR 识别成文本,然后对识别到的文本进行技能匹配,交给适合处理该指令的技能插件去处理。插件处理完成后,得到的结果再交给 TTS 引擎合成成语音,播放给用户。 | ||
|
||
虽然一次交互可能包含多次网络请求,不过带来的好处是:每一个环节都可以被修改和定制。 | ||
|
||
## Demo | ||
|
||
详见 [Demo](https://github.com/dingdang-robot/dingdang-robot/wiki/demo) | ||
|
||
## 硬件要求 | ||
|
||
* Raspberry Pi 全系列,或其他 Linux 主机; | ||
* USB 麦克风(建议选购麦克风阵列); | ||
* 音箱(不建议蓝牙音箱); | ||
* 至少 8G 的 Micro-SD 内存卡(刷镜像要求内存卡的实际容量至少 7.9 GB,否则可能刷不成功); | ||
* 摄像头(可选,用于拍照)。 | ||
* 读卡器(可选,用于刷镜像进内存卡)。 | ||
|
||
如果不知道怎么选择,可以参考 [硬件选购建议](https://github.com/dingdang-robot/dingdang-robot/wiki/hardware-choices) 。 | ||
|
||
## 安装 | ||
|
||
### 镜像安装 | ||
|
||
推荐使用镜像安装的方式,像安装 Raspbian 系统一样,安装完后,只需要少量的配置即可立即使用叮当机器人。 | ||
|
||
* [下载地址](https://github.com/dingdang-robot/dingdang-robot/wiki/changelog) | ||
|
||
镜像安装方法详见 [镜像安装](https://github.com/dingdang-robot/dingdang-robot/wiki/install#%E9%95%9C%E5%83%8F%E5%AE%89%E8%A3%85) 。 | ||
|
||
刷完后记得在启动系统后进入 `raspi-config` 的高级选项中开启 Extend FileSystem,以让内存卡中的剩余空间合并到主分区中。 | ||
|
||
### 手动安装 | ||
|
||
见 [手动安装](https://github.com/dingdang-robot/dingdang-robot/wiki/install)。 | ||
|
||
## 升级 | ||
|
||
``` sh | ||
cd /home/pi/dingdang | ||
git pull | ||
``` | ||
|
||
## 配置 | ||
|
||
请参考 [配置](https://github.com/dingdang-robot/dingdang-robot/wiki/configuration) 。 | ||
|
||
## 运行 | ||
|
||
``` sh | ||
cd /home/pi/dingdang | ||
python dingdang.py | ||
``` | ||
|
||
建议在 [tmux](http://blog.jobbole.com/87278/) 或 supervisor 中执行。 | ||
|
||
运行过程中的 log 可以在启动后使用如下命令查阅: | ||
|
||
``` sh | ||
tail -f temp/dingdang.log | ||
``` | ||
|
||
如果希望运行过程中直接在屏幕中打印 log ,可以使用如下命令: | ||
|
||
``` sh | ||
python dingdang.py --verbose | ||
``` | ||
|
||
## 退出 | ||
|
||
先使用 `Ctrl-Z` 退出当前会话,然后执行如下命令: | ||
|
||
``` sh | ||
ps auwx | grep dingdang # 查看dingdang的PID号 | ||
kill -9 PID号 | ||
``` | ||
|
||
## 插件 | ||
|
||
* [官方插件列表](https://github.com/dingdang-robot/dingdang-robot/wiki/plugins) | ||
* [第三方插件](https://github.com/dingdang-robot/dingdang-contrib) | ||
|
||
|
||
## 贡献 | ||
|
||
* 喜欢本项目请先打一颗星; | ||
* 提 bug 请到 [issue 页面](https://github.com/dingdang-robot/dingdang-robot/issues); | ||
* 要贡献代码,欢迎 fork 之后再提 pull request; | ||
* 插件请提交到 [dingdang-contrib](https://github.com/dingdang-robot/dingdang-contrib) ; | ||
* 您的捐赠将鼓励我继续完善叮当,支持支付宝、微信等捐赠形式。捐赠的时候,请备注下您的昵称或姓名,我将会把您备注的信息添加到 [捐赠者名单](https://github.com/dingdang-robot/dingdang-robot/wiki/donate-list) 中: | ||
|
||
| 支付宝 | 微信支付 | | ||
| ------ | --------- | | ||
| <img src="https://camo.githubusercontent.com/02137cc531856c56345624f0d97b8588ff333a07/687474703a2f2f37786a3839692e636f6d312e7a302e676c622e636c6f7564646e2e636f6d2f616c695f7061795f30312e6a7067" height="248px" width="164px" title="支付宝" style="display:inherit;"/> | <img src="https://camo.githubusercontent.com/8d283b5d11d87fed1760405b468ebb28b991d14b/687474703a2f2f37786a3839692e636f6d312e7a302e676c622e636c6f7564646e2e636f6d2f7765636861745f7061795f30322e706e67" height="248px" width="164px" title="微信支付" style="display:inherit;"/> | | ||
|
||
|
||
## 联系 | ||
|
||
* 叮当的主要开发者是 [潘伟洲](http://hahack.com) 。 | ||
* QQ 群:580447290(人数将满,为控制人数,需付费20元入群) | ||
* 论坛:[bbs.hahack.com](http://bbs.hahack.com) | ||
|
||
## 感谢 | ||
|
||
* 叮当的前身是 [jasper-client](https://github.com/jasperproject/jasper-client)。感谢 [Shubhro Saha](http://www.shubhro.com/), [Charles Marsh](http://www.crmarsh.com/) and [Jan Holthuis](http://homepage.ruhr-uni-bochum.de/Jan.Holthuis/) 在 Jasper 项目上做出的优秀贡献; | ||
* 微信机器人使用的是 [liuwons](http://lwons.com/) 的 [wxBot](https://github.com/liuwons/wxBot)。 | ||
* 感谢果果 [@qwedc001](http://github.com/qwedc001) 帮忙搭建维护 [论坛](http://bbs.hahack.com) 。 | ||
* 感谢 [@GoldJohnKing](https://github.com/GoldJohnKing) 设计了叮当的 [logo](https://github.com/dingdang-robot/dingdang-robot/issues/39) 。 | ||
|
||
## FAQ | ||
|
||
- 我能否更换成其他唤醒词,而不是叫“叮当”? | ||
|
||
- 能。参见 [修改唤醒词](https://github.com/dingdang-robot/dingdang-robot/wiki/configuration#%E9%85%8D%E7%BD%AE%E9%BA%A6%E5%85%8B%E9%A3%8E) 。[项目站点](http://dingdang.hahack.com) 置顶的视频就演示了与一个名为“小梅”的机器人聊天。 | ||
|
||
- 百度不太能够准确识别我的指令,怎么办? | ||
|
||
- 参见 [优化百度语音识别准确度](https://github.com/dingdang-robot/dingdang-robot/wiki/configuration#%E4%BC%98%E5%8C%96%E7%99%BE%E5%BA%A6%E8%AF%AD%E9%9F%B3%E8%AF%86%E5%88%AB%E5%87%86%E7%A1%AE%E5%BA%A6) 。 | ||
|
||
- 为什么取名为“叮当”? | ||
|
||
- 我一开始有多个候选唤醒词,但我发现”叮当“在离线唤醒词中准确率最高。所以取名为“叮当”。 | ||
|
||
- 我想了解你的系统镜像都做了哪些定制? | ||
|
||
- 请参见 [dingdang 镜像与 Raspbian 系统的区别](https://github.com/dingdang-robot/dingdang-robot/wiki/different-with-raspbian) 。 | ||
|
||
- pi 账户默认登录密码是啥? | ||
|
||
- 与 Raspbian 系统默认密码相同,都是 raspberry 。 | ||
|
||
## 免责声明 | ||
|
||
* 叮当只用作个人学习研究,如因使用叮当导致任何损失,本人概不负责。 | ||
* 本开源项目与腾讯叮当助手没有任何关系。 | ||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-cayman |
Oops, something went wrong.