Giter Site home page Giter Site logo

dingdang-contrib's Introduction

叮当——中文语音对话机器人

GitHub tag Travis GitHub issues GitHub pull requests GitHub pull requests QQ群

注意:本项目已不再维护。请关注 wukong-robot 项目。目的是提供一个更快、更稳定、更容易搭建的机器人,同时兼容dingdang-robot的插件机制。

叮当是一款可以工作在 Raspberry Pi 上的开源中文语音对话机器人/智能音箱项目,目的是让中国的Hacker们也能快速打造个性化的智能音箱。

dingdang

 
 

Table of Contents

特性

叮当的特性

叮当包括以下诸多特性:

  • 模块化。功能插件、语音识别、语音合成、对话机器人都做到了高度模块化,第三方插件单独维护,方便继承和开发自己的插件。
  • 微信接入。支持接入微信,并通过微信远程操控自己家中的设备。
  • 中文支持。集成百度、科大讯飞、阿里、谷歌等多家中文语音识别和语音合成技术,且可以继续扩展。
  • 对话机器人支持。支持接入图灵机器人、Emotibot,未来还将支持接入更多机器人。
  • 全局监听,离线唤醒。支持无接触地离线语音指令唤醒。
  • 灵活可配置。支持定制机器人名字,支持选择语音识别和合成的插件。
  • 智能家居。集成 HomeAssistant 插件,支持语音控制智能家电。

叮当的工作模式:

叮当的工作模式

叮当被唤醒后,用户的语音指令先经过在线 STT 引擎进行 ASR 识别成文本,然后对识别到的文本进行技能匹配,交给适合处理该指令的技能插件去处理。插件处理完成后,得到的结果再交给 TTS 引擎合成成语音,播放给用户。

虽然一次交互可能包含多次网络请求,不过带来的好处是:每一个环节都可以被修改和定制。

Demo

详见 Demo

硬件要求

  • Raspberry Pi 全系列,或其他 Linux 主机;
  • USB 麦克风(建议选购麦克风阵列);
  • 音箱(不建议蓝牙音箱);
  • 至少 8G 的 Micro-SD 内存卡(刷镜像要求内存卡的实际容量至少 7.9 GB,否则可能刷不成功);
  • 摄像头(可选,用于拍照)。
  • 读卡器(可选,用于刷镜像进内存卡)。

如果不知道怎么选择,可以参考 硬件选购建议

安装

镜像安装

推荐使用镜像安装的方式,像安装 Raspbian 系统一样,安装完后,只需要少量的配置即可立即使用叮当机器人。

镜像安装方法详见 镜像安装

刷完后记得在启动系统后进入 raspi-config 的高级选项中开启 Extend FileSystem,以让内存卡中的剩余空间合并到主分区中。

手动安装

手动安装

升级

cd /home/pi/dingdang
git pull

配置

请参考 配置

运行

cd /home/pi/dingdang
python dingdang.py

建议在 tmux 或 supervisor 中执行。

运行过程中的 log 可以在启动后使用如下命令查阅:

tail -f temp/dingdang.log

如果希望运行过程中直接在屏幕中打印 log ,可以使用如下命令:

python dingdang.py --verbose

退出

先使用 Ctrl-Z 退出当前会话,然后执行如下命令:

ps auwx | grep dingdang  # 查看dingdang的PID号
kill -9 PID号

插件

贡献

  • 喜欢本项目请先打一颗星;
  • 提 bug 请到 issue 页面
  • 要贡献代码,欢迎 fork 之后再提 pull request;
  • 插件请提交到 dingdang-contrib
  • 您的捐赠将鼓励我继续完善叮当,支持支付宝、微信等捐赠形式。捐赠的时候,请备注下您的昵称或姓名,我将会把您备注的信息添加到 捐赠者名单 中:
支付宝 微信支付

联系

  • 叮当的主要开发者是 潘伟洲
  • QQ 群:580447290(人数将满,为控制人数,需付费20元入群)
  • 论坛:bbs.hahack.com

感谢

FAQ

  • 我能否更换成其他唤醒词,而不是叫“叮当”?

  • 百度不太能够准确识别我的指令,怎么办?

  • 为什么取名为“叮当”?

    • 我一开始有多个候选唤醒词,但我发现”叮当“在离线唤醒词中准确率最高。所以取名为“叮当”。
  • 我想了解你的系统镜像都做了哪些定制?

  • pi 账户默认登录密码是啥?

    • 与 Raspbian 系统默认密码相同,都是 raspberry 。

免责声明

  • 叮当只用作个人学习研究,如因使用叮当导致任何损失,本人概不负责。
  • 本开源项目与腾讯叮当助手没有任何关系。

dingdang-contrib's People

Contributors

bertsir avatar chuanlongchen avatar deschanel avatar helloyinwei avatar hhao avatar isaiasyang avatar lijianfex avatar musistudio avatar olive900 avatar qchaol avatar shark526 avatar sigrace1111 avatar spendist avatar wzpan avatar yunxiyinzhe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dingdang-contrib's Issues

叮当接入hass

叮当语音和homeassistant连接控制开关灯的视频。我想请教你一下,叮当的官方文档说的在叮当配置文件里添加ip和端口和密码,这里不用填用户名的话不能登录hass呀,那还是填mqtt服务器的ip啊?hass的customeize.yaml文件也弄好了也include进去了,就是叮当配置那里搞不定了

想做一个基于叮当的聊天插件

大概使用方法是每个安装叮当的用户先去一个网站注册,然后可以直接和叮当说话,然后叮当其他的使用者可以通过叮当听到这条消息,不知道有没有感兴趣的友友

key words of my contrib have been detected, when i check in verbose log.however,error ocurred

as i mentioned above, i 've finished my contrib, i found dingdang has detected key WORDS of my code though --verbose, however, the error occurred as follows,why?

2018-03-08 21:30:38,380 stt.py[line:446] INFO 讯飞语音识别到了: 星。
Traceback (most recent call last):
File "dingdang.py", line 178, in
app.run()
File "dingdang.py", line 125, in run
conversation.handleForever()
File "/home/pi/dingdang/client/conversation.py", line 86, in handleForever
self.brain.query(input, self.wxbot)
File "/home/pi/dingdang/client/brain.py", line 105, in query
if plugin.isValid(text) and self.isEnabled(plugin):
File "/home/pi/dingdang/client/brain.py", line 79, in isEnabled
if slug in self.profile and 'enable' in self.profile[slug]:
TypeError: argument of type 'NoneType' is not iterable
2018-03-08 21:30:38,383 base.py[line:159] INFO Scheduler has been shut down

returned with non-zero exit status '255'

INFO: ngram_search_fwdflat.c(157): fwdflat: min_ef_width = 4, max_sf_win = 25
2018-03-22 21:48:13,420 vocabcompiler.py[line:163] INFO Starting compilation...
2018-03-22 21:48:14,926 vocabcompiler.py[line:168] ERROR Fatal compilation Error occured, cleaning up...
Traceback (most recent call last):
File "/home/pi/dingdang/client/vocabcompiler.py", line 165, in compile
self._compile_vocabulary(phrases)
File "/home/pi/dingdang/client/vocabcompiler.py", line 271, in _compile_vocabulary
vocabulary = self._compile_languagemodel(text, self.languagemodel_file)
File "/home/pi/dingdang/client/vocabcompiler.py", line 296, in _compile_languagemodel
cmuclmtk.text2lm(text, output_file, vocab_file=vocab_file)
File "/usr/local/python/2.7.14/lib/python2.7/site-packages/cmuclmtk/init.py", line 509, in text2lm
output1 = text2idngram(text, vocab_file=used_vocab_file, output_file=idngram_file, **text2idngram_kwargs)
File "/usr/local/python/2.7.14/lib/python2.7/site-packages/cmuclmtk/init.py", line 237, in text2idngram
raise ConversionError("'%r' returned with non-zero exit status '%s'" % (cmd, exitcode))
ConversionError: '['text2idngram', '-vocab', '/tmp/tmpv6aFE0.vocab', '-idngram', '/tmp/tmpADdc1t.idngram', '-buffer', '100', '-hash', '2000000', '-files', '20', '-verbosity', '2', '-n', '3', '-fof_size', '10']' returned with non-zero exit status '255'

你好
启动的时候出现了上面的错误,
我打印了一下 phrases是空,请指引一下方向。

网易音乐无法识别关键词

2018-12-27 19:05:00,903 config.py[line:81] WARNING: statistic not specified in profile, defaulting to 'True'
2018-12-27 19:05:07,008 stt.py[line:321] INFO: 百度语音识别到了: 播放音乐。
2018-12-27 19:05:08,251 mic.py[line:351] INFO: 机器人说:那咱们边听歌,边聊天吧。
2018-12-27 19:05:08,252 tts.py[line:124] INFO: found speech in cache, playing...[/home/pi/dingdang/temp/baidu-ttsb18c7826886a19009d64bf1e725a89aa.mp3]

emmm.我自己锁了,好像是插件没有加载进来的样子。

网易云的插件希望能改进一下。

网易云的插件希望能改进一下。每播放一首歌之前都要说一次歌手及歌曲名,比较烦人。希望把这个烦人的部分去掉,直接播放就行了。

/home/pi文件夹权限问题导致开机自动启动的叮当无法登陆网易云音乐

开机用rc.local启动的时候叮当用的是root账户,/home/pi文件夹默认不允许pi以外的其他用户修改和写入内容。
也就是说,由于网易云音乐的登陆缓存文件夹存放于pi,网易云音乐在登陆的时候会出现错误。提示“我的大脑出故障了”。歌单更新也无法进行。

2017-08-06
最新的开机启动方案已解决此问题,故本issue关闭。

高德路况插件无法加入

加入高德路况插件后,会报错无法运行
2018-11-24 15:05:28,148 dingdang.py[line:136] ERROR: Error occured!
Traceback (most recent call last):
File "dingdang.py", line 134, in
app = Dingdang()
File "dingdang.py", line 61, in init
stt_engine_class.get_active_instance())
File "/home/pi/dingdang/client/stt.py", line 70, in get_active_instance
phrases = vocabcompiler.get_all_phrases()
File "/home/pi/dingdang/client/vocabcompiler.py", line 522, in get_all_phrases
plugins = plugin_loader.get_plugins()
File "/home/pi/dingdang/client/plugin_loader.py", line 102, in get_plugins
init_plugins()
File "/home/pi/dingdang/client/plugin_loader.py", line 65, in init_plugins
if config.has(mod.SLUG) and 'enable' in config.get(mod.SLUG):
TypeError: argument of type 'NoneType' is not iterable

网易云插件BUG

开启播放后,然后退出播放,过一会自己又自动播放了

网易云音乐插件无法播放

大神帮看看是否是bug啊?我用的是最新叮当固件,网易云音乐也是通过手机注册且提示登录成功,但运行后报错,通过语音退出后就不响应任何指令了...
2018-08-15 09:14:37,278 plugin_loader.py[line:67] INFO: plugin 'Email' is disabled
2018-08-15 09:14:38,195 mic.py[line:45] INFO: Initializing PyAudio. ALSA/Jack error messages that pop up during this process are normal and can usually be safely ignored.
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
2018-08-15 09:14:38,254 mic.py[line:52] INFO: Initialization of PyAudio completed.
2018-08-15 09:14:38,256 config.py[line:81] WARNING: sound_engine not specified in profile, defaulting to 'pyaudio'
2018-08-15 09:14:38,378 base.py[line:132] INFO: Scheduler started
2018-08-15 09:14:38,464 base.py[line:743] INFO: Added job "Notifier.gather" to job store "default"
2018-08-15 09:14:38,731 config.py[line:81] WARNING: statistic not specified in profile, defaulting to 'True'
2018-08-15 09:14:38,850 mic.py[line:351] INFO: 机器人说:您好,我能为您做什么?
2018-08-15 09:14:38,851 tts.py[line:124] INFO: found speech in cache, playing...[/home/pi/dingdang/temp/baidu-tts023b4f3affe25cb0c448d3f7439f5bb9.mp3]
2018-08-15 09:14:38,852 config.py[line:81] WARNING: music_engine not specified in profile, defaulting to 'play'
2018-08-15 09:14:39,909 conversation.py[line:59] INFO: Starting to handle conversation with keyword 'HEYDINGDANG'.
2018-08-15 09:14:46,199 stt.py[line:207] INFO: PocketSphinx 识别到了:['HEYDINGDANG']
2018-08-15 09:14:46,200 conversation.py[line:84] INFO: Keyword 'HEYDINGDANG' has been said!
2018-08-15 09:14:46,460 config.py[line:81] WARNING: statistic not specified in profile, defaulting to 'True'
2018-08-15 09:14:54,774 stt.py[line:321] INFO: 百度语音识别到了: 音乐,
2018-08-15 09:14:56,030 NetEaseMusic.py[line:311] INFO: 离线唤醒监听中
2018-08-15 09:14:56,063 api.py[line:106] DEBUG: {"csrf_token": "a69bb6cc0bd799ea905303efa501ff4f", "ids": [1296583188], "br": 320000}
Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/home/pi/.dingdang/contrib/NetEaseMusic.py", line 499, in run
self.play()
File "/home/pi/.dingdang/contrib/NetEaseMusic.py", line 520, in play
[song['song_id']])[0]['url']
File "/usr/local/lib/python2.7/dist-packages/MusicBoxApi/api.py", line 551, in songs_detail_new_api
return result['data']
KeyError: u'data'

2018-08-15 09:15:06,611 NetEaseMusic.py[line:318] INFO: Nothing has been said or transcribed.
2018-08-15 09:15:06,612 NetEaseMusic.py[line:311] INFO: 离线唤醒监听中
2018-08-15 09:15:09,339 stt.py[line:207] INFO: PocketSphinx 识别到了:['']
2018-08-15 09:15:09,340 NetEaseMusic.py[line:318] INFO: Nothing has been said or transcribed.
2018-08-15 09:15:09,341 NetEaseMusic.py[line:311] INFO: 离线唤醒监听中
2018-08-15 09:15:11,395 stt.py[line:207] INFO: PocketSphinx 识别到了:['']
2018-08-15 09:15:11,396 NetEaseMusic.py[line:318] INFO: Nothing has been said or transcribed.
2018-08-15 09:15:11,397 NetEaseMusic.py[line:311] INFO: 离线唤醒监听中
2018-08-15 09:15:14,065 stt.py[line:207] INFO: PocketSphinx 识别到了:['HEYDINGDANG']
2018-08-15 09:15:22,036 stt.py[line:321] INFO: 百度语音识别到了: 退出播放,
2018-08-15 09:15:22,038 mic.py[line:351] INFO: 机器人说:结束播放
2018-08-15 09:15:22,039 tts.py[line:124] INFO: found speech in cache, playing...[/home/pi/dingdang/temp/baidu-tts224be4a2887086d65e2c763bf52193a6.mp3]

运行网易云音乐插件时模块from builtins import chr无法导入

报错内容如下:2018-10-28 19:22:10,344 plugin_loader.py[line:50] WARNING: Skipped plugin 'NetEaseMusic' due to an error.
Traceback (most recent call last):
File "/home/pi/dingdang/client/plugin_loader.py", line 47, in init_plugins
mod = loader.load_module(name)
File "/usr/lib/python2.7/pkgutil.py", line 246, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/home/pi/.dingdang/contrib/NetEaseMusic.py", line 12, in
from MusicBoxApi import api as NetEaseApi
File "/home/pi/.local/lib/python2.7/site-packages/MusicBoxApi/api.py", line 12, in
from builtins import chr
ImportError: No module named builtins
遇到这种情况是什么原因引起的呢?有谁遇到过类似的问题吗?帮忙解答一下,谢谢!

ubuntu中安装叮当,我也查看了常见问题,重新安装了pip还是一样

Traceback (most recent call last):
File "dingdang.py", line 11, in
from client import tts
File "/home/patrickliu/dingdang/client/tts.py", line 32, in
from . import diagnose
File "/home/patrickliu/dingdang/client/diagnose.py", line 10, in
import pip.req
File "/home/patrickliu/.local/lib/python2.7/site-packages/pip/init.py", line 45, in
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/home/patrickliu/.local/lib/python2.7/site-packages/pip/vcs/mercurial.py", line 9, in
from pip.download import path_to_url
File "/home/patrickliu/.local/lib/python2.7/site-packages/pip/download.py", line 40, in
from pip._vendor import requests, six
File "/home/patrickliu/.local/lib/python2.7/site-packages/pip/_vendor/requests/init.py", line 98, in
from . import packages
File "/home/patrickliu/.local/lib/python2.7/site-packages/pip/_vendor/requests/packages.py", line 12, in
sys.modules['pip._vendor.requests.packages.' + mod] = sys.modules["pip._vendor." + mod]
KeyError: 'pip._vendor.urllib3.contrib'

网易云音乐插件优化

改播放器为Omxplayer, 原因是

  • Omxplayer是pi专用有,有做专门优化,参考这里
  • 支持暂停操作,可以参考这个问答

ps:可以做一个本地的播放列表了,音乐也放本地。

网易云插件存在可能无法播放音乐和导致语音识别启动时间过短的情况

叮当在播放音乐时偶尔会出现读了歌曲名但实际上没有播放的情况,log如下:

INFO:client.stt:PocketSphinx 识别到了:['HEYDINGDANG']
INFO:client.stt:阿里云语音识别到了: 播放音乐
ERROR:MusicBoxApi.api:[Errno 2] No such file or directory: u'/root/.netease-musicbox/cookie'
DEBUG:MusicBoxApi.api:{"phone": "15541769173", "password": "f1afe316cd4fadaad3bbc3969bd1934e", > "rememberLogin": "true"}
/bin/sh: 1: task: not found
ERROR:client.app_utils:invalid literal for int() with base 10: ''
DEBUG:MusicBoxApi.api:{"csrf_token": "6fc30568fe26c085791285b9c093befd", "ids": [506092035], "br": 320000}
[DEBUG] sync_check: -1 -1

另外,一旦log中出现[DEBUG] sync_check: -1 -1,依然有语音识别过晚开始和过早结束,无法把握说话时机的情况。而且据观察,在音乐播放以外的地方并没有出现过该提示。

网页云音乐退出播放后微信使用异常

语音唤醒并播放音乐
语音或微信“退出播放”
结束播放,然后所有微信消息将会接受到两条,并相应两次,多次播放音乐并退出后,微信将会重复多遍收到相同消息并相应。
推测是退出播放是这种wxbot对象状态出问题,或者wxbot插件本身存在问题。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.