Git Product home page Git Product logo

dingdang-robot's Introduction

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

注意:本项目已迁移到 dingdang-robot/dingdang-robot ,当前仓库将归档,不再更新维护。

已经使用了 dingdang 的用户,如需正常获得更新支持,可以切换 dingdang 的仓库地址:

cd $HOME/dingdang
git remote remove origin
git remote add origin https://github.com/dingdang-robot/dingdang-robot.git

叮当是一款可以工作在 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-robot's People

Contributors

bubble6 avatar deschanel avatar happycool333 avatar helloyinwei avatar kira8565 avatar musistudio avatar shark526 avatar wmatrix 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  avatar  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar

dingdang-robot's Issues

无法唤醒报错

Traceback (most recent call last):
File "dingdang.py", line 228, in
app.run()
File "dingdang.py", line 181, in run
self.mic.say(salutation)
File "/home/pi/dingdang/client/mic.py", line 340, in say
self.speaker.say(phrase)
File "/home/pi/dingdang/client/tts.py", line 587, in say
tmpfile = self.get_speech(phrase)
File "/home/pi/dingdang/client/tts.py", line 579, in get_speech
r = requests.get(voice_url)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='proxy.peiyinge.com', port=17063): Max retries exceeded with url: /synth?ts=1510863836&sign=291f287a7dbb784bc0aa35b4e3828406&vid=65360&volume=&speed=0&content=%E4%BC%9F%E6%B4%B2%20%E6%88%91%E8%83%BD%E4%B8%BA%E6%82%A8%E5%81%9A%E4%BB%80%E4%B9%88%3F (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73fb6410>: Failed to establish a new connection: [Errno 110] Connection timed out',))

请教麦克风的选取

麦克风一定要选择全向的么?目前TB上全向的价格不一,实验用那种合适?

科大讯飞调用不成功

提示
"code":"10004","desc":"无效的CheckSum","data":null
有人知道为什么吗

问题找到了
headers = {
'X-Appid': self.api_id,
'X-CurTime': str(int(time.time())),
'X-Param': XParam,
'X-CheckSum': checksum
}
这样就对了

更换唤醒词时遇到错误

Languagemodel 能成功生成,然后在生成 Dictionary的时候出现这错误:

phonetisaurus-g2p: error while loading shared libraries: libfst.so.1: cannot open shared object file: No such file or directory

我是用镜像源直接用的

谢谢

hardware choices WIKI页面关于PlayStation Eye的描述有误

麦克风-四阵列:

PS4 eyes - PS4 淘汰的配件,包含四阵列麦克风和摄像头,免驱使用。由于是淘汰下来的配件,价格也比较便宜,可以到淘宝上找找。

PS4 eyes应该修改为PS3 Eye或者PlayStation Eye,属于PS3的淘汰配件。

手动安装遇到的问题

Hi wzpan,

我想在本地手动安装环境,stt_passive_engine想使用snowboy

wiki的安装文档里不知能否补上这个

能不能把Goolge TTS engine加进去?

希望能照顾一下使用粤语的朋友。
stt.py文件中百度STT增加一项"lan": 'ct'就能识别粤语,但百度TTS暂时还不能合成粤语。
配音阁的讯飞粤语发音人小梅是十多年前的语音库,发音不准而且跟不上潮流。

而Google TTS engine的粤语语音库对比讯飞的小梅犹如天籁之音。
经对照原jasper的tts.py文件,稍加修改我把Google TTS engine加进去。
虽然要用上Google的STT有点难度,但是要用上Google TTS engine还是比较容易的,希望能完善一下加上Google TTS engine。

镜像链接过期

想直接试一下镜像安装,发现分享链接过期,以后还会放出来吗?

pocketsphinx离线语音库增添功能

如题所说,比如唤醒词是叮当,但是我想加一个亮灯的功能,自己已经写好源代码led.py(灯就直接插在树莓派板子上)。
当我说“亮灯”——哪怕说light时,能识别出来直接亮灯(不用调用在线API);而当我说“叮当”的时候,又能切换回叮当主程序,去调用在线API和stt
希望有大佬能给一点启发~
这边自己看了一个用pocketsphinx下面的continuous.c的方式来弄的,虽然可以做到语音控制亮灯,但是无法和叮当兼容~

运行python dingdang.py提示错误

S805 debian,1GB DDR
信息如下:
Traceback (most recent call last):
File "dingdang.py", line 16, in
from client.conversation import Conversation
File "/home/kevin/dingdang/client/conversation.py", line 6, in
from drivers.pixels import pixels
File "/home/kevin/dingdang/client/drivers/pixels.py", line 124, in
pixels = Pixels()
File "/home/kevin/dingdang/client/drivers/pixels.py", line 21, in init
self.dev = apa102.APA102(num_led=self.PIXELS_N)
File "/home/kevin/dingdang/client/drivers/apa102.py", line 90, in init
self.spi.open(bus, device) # Open SPI port 0, slave device (CS) 1
IOError: [Errno 2] No such file or directory

ImportError: cannot import name InsecureRequestWarning

运行的时候报这个问题
No handlers could be found for logger "cmuclmtk"
Traceback (most recent call last):
File "dingdang.py", line 12, in
from client import stt
File "/root/dingdang/client/stt.py", line 22, in
from requests.packages.urllib3.exceptions import InsecureRequestWarning
ImportError: cannot import name InsecureRequestWarning

关于叮当开机自启前增加自动升级的建议

如果希望叮当开机自启前自动升级,可以用以下文件内容替代已有的"dingdang.sh"文件中的内容。

对于希望以root身份启动叮当的用户:
dingdang-AutoUpdate-Launcher-for-root-User.sh

#!/bin/bash
sleep 1

#Delete Cache
sudo rm -r /root/.cache
sudo rm -r /root/.netease-musicbox
sudo rm -r /root/userInfo
sleep 1

#Update dingdang-robot
cd /home/pi/dingdang
git pull

#Update dingdang-contrib
cd /home/pi/.dingdang/contrib
git pull

#Update dingdang-contrib Requirements
sudo pip install --upgrade -r requirements.txt
sleep 1

#Restore Configuration of AlsaMixer
alsactl --file=/home/pi/asound.state restore
sleep 1

#Launch Dingdang in LxTerminal
sudo lxterminal -e "python /home/pi/dingdang/dingdang.py"
sleep 1

#Start Respeaker-Switcher in Background
sudo python /home/pi/ReSpeaker-Switcher/switcher.py &

对于希望以pi身份启动叮当的用户:
dingdang-AutoUpdate-Launcher-for-pi-User.sh

#!/bin/bash
sleep 1

#Delete Cache
sudo rm -r /home/pi/.cache
sudo rm -r /home/pi/.netease-musicbox
sudo rm -r /home/pi/userInfo
sleep 1

#AutoUpdate Before Launch
#Update dingdang-robot
cd /home/pi/dingdang
git pull

#Update dingdang-contrib
cd /home/pi/.dingdang/contrib
git pull

#Update dingdang-contrib Requirements
sudo pip install --upgrade -r requirements.txt
sleep 1

#Restore Configuration of AlsaMixer
alsactl --file=/home/pi/asound.state restore
sleep 1

#Launch Dingdang in LxTerminal
lxterminal -e "python /home/pi/dingdang/dingdang.py"
sleep 1

#Start Respeaker-Switcher in Background
sudo python /home/pi/ReSpeaker-Switcher/switcher.py &

另外,个人建议在叮当启动前清除其缓存,因为测试发现网易云音乐播放插件在某些情况下可能由于缓存问题导致默认播放列表长期不刷新。具体如下:
dingdang-Launch-without-Update.sh

#!/bin/bash
sleep 1

#Delete Cache
sudo rm -r /root/.cache
sudo rm -r /root/.netease-musicbox
sudo rm -r /root/userInfo

#Restore Configuration of AlsaMixer
alsactl --file=/home/pi/asound.state restore
sleep 1

#Start DingDang
sudo lxterminal -e "python /home/pi/dingdang/dingdang.py"
sleep 1
sudo python /home/pi/ReSpeaker-Switcher/switcher.py &

强烈建议将开机前自动升级功能加入到下一版本的镜像中,同时建议增加关于这一方面的Wiki内容。

日程提醒功能

增加日程提醒功能(暂时只支持 Emotibot)。

先利用 Emotibot 的返回提取出日程。

{
    "remind_info": [
        {
            "remind_period": "0",
            "remind_event": "吃饭",
            "remind_time_info": "2017年9月4日  周一 09:00",
            "remind_time": "20170904090000"
        }
    ],
    "time_zone": "8",
    "inference_type": "INFERENCE_BUILT",
    "text_answer": "叮当会在2017年9月4日  周一 09:00提醒你吃饭",
    "gap_time": "",
    "period": 0,
    "time": "20170904090000",
    "answer": "创建提醒成功!",
    "isRemindCancel": false,
    "event": "吃饭"
}

之后利用 TaskWarrior 来创建和查询任务。

hmm 库默认安装路径可能与叮当指定路径不符,手动安装需要修改下路径

wiki中安装方式:

wget http://downloads.sourceforge.net/project/cmusphinx/sphinxbase/0.8/sphinxbase-0.8.tar.gz
tar -zxvf sphinxbase-0.8.tar.gz
cd ~/sphinxbase-0.8/
./configure --enable-fixed
make
sudo make install
wget http://downloads.sourceforge.net/project/cmusphinx/pocketsphinx/0.8/pocketsphinx-0.8.tar.gz
tar -zxvf pocketsphinx-0.8.tar.gz
cd ~/pocketsphinx-0.8/
./configure
make
sudo make install

安装完成后 hmm 在 /home/pi/sphinxbase-0.8

运行python dingdang.py 报错如下

ERROR:client.stt:hmm_dir '/usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k' does not exist! Please make sure that you have set the correct hmm_dir in your profile.
ERROR:root:Error occured!
Traceback (most recent call last):
  File "dingdang.py", line 186, in <module>
    app = Dingdang()
  File "dingdang.py", line 127, in __init__
    stt_passive_engine_class.get_passive_instance(),
  File "/home/pi/dingdang/client/stt.py", line 58, in get_passive_instance
    return cls.get_instance('keyword', phrases)
  File "/home/pi/dingdang/client/stt.py", line 52, in get_instance
    instance = cls(**config)
  File "/home/pi/dingdang/client/stt.py", line 120, in __init__
    raise RuntimeError(msg)
RuntimeError: hmm_dir '/usr/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k' does not exist! Please make sure that you have set the correct hmm_dir in your profile.

手动修改路径和文件夹名字后运行成功

百度tts和stt的token可以本地缓存一下

import time
from dateutil import parser

def get_token(self):
    cache = open(dingdangpath.TEMP_PATH+'/baidustt.ini' , 'a+')
            try:
                pms = cache.readlines()
                if len(pms) > 0:
                    time = pms[0]
                    tk = pms[1]
                    # 计算token是否过期 官方说明一个月,这里保守29天
                    time = parser.parse(time)
                    endtime = datetime.datetime.now()
                    if (endtime - time).days <= 29:
                        return tk
            finally:
                cache.close()
    URL = 'http://openapi.baidu.com/oauth/2.0/token'
            params = urllib.urlencode({'grant_type': 'client_credentials',
                                       'client_id': self.api_key,
                                       'client_secret': self.secret_key})
            r = requests.get(URL, params=params)
            try:
                r.raise_for_status()
                token = r.json()['access_token']
                # 存储token
                try:
                    cache = open(dingdangpath.TEMP_PATH+'/baidustt.ini' , 'w')
                    cache.write(str(datetime.datetime.now()) + '\n')
                    cache.write(token)
                finally:
                    cache.close()
                return token
            except requests.exceptions.HTTPError:
                self._logger.critical('Token request failed with response: %r',
                                      r.text,
                                      exc_info=True)
                return ''

启动后报错

[INFO] Please use WeChat to scan the QR code .
Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2048
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->capture, inParams, self->primeBuffers, hwParamsCapture, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2719
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Traceback (most recent call last):
File "./dingdang.py", line 188, in
app.run()
File "./dingdang.py", line 154, in run
conversation.handleForever()
File "/home/pi/dingdang/client/conversation.py", line 63, in handleForever
threshold, transcribed = self.mic.passiveListen(self.persona)
File "/home/pi/dingdang/client/mic.py", line 140, in passiveListen
frames_per_buffer=CHUNK)
File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 747, in open
stream = Stream(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 442, in init
self._stream = pa.open(**arguments)
IOError: [Errno Invalid sample rate] -9997
[INFO] Please confirm to login .
[INFO] Web WeChat login succeed .
[INFO] Web WeChat init succeed .
[INFO] Get 155 contacts
[INFO] Start to process messages .
ERROR:apscheduler.executors.default:Job "Notifier.gather (trigger: interval[0:00:30], next run at: 2017-08-05 06:23:20 HKT)" raised an exception
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/apscheduler/executors/base.py", line 108, in run_job
retval = job.func(*job.args, **job.kwargs)
File "/home/pi/dingdang/client/notifier.py", line 41, in gather
[client.run() for client in self.notifiers]
File "/home/pi/dingdang/client/notifier.py", line 18, in run
self.timestamp = self.gather(self.timestamp)
File "/home/pi/dingdang/client/notifier.py", line 45, in handleEmailNotifications
emails = Email.fetchUnreadEmails(self.profile, since=lastDate)
File "/home/pi/dingdang/client/plugins/Email.py", line 141, in fetchUnreadEmails
conn.login(profile[SLUG]['address'], profile[SLUG]['password'])
File "/usr/lib/python2.7/imaplib.py", line 519, in login
raise self.error(dat[-1])
error: LOGIN Login error

扫码后报错,无法进行声音识别,请看一下是什么问题

网易云音乐找不到正确的音乐url

请问网易云音乐插件可以正常使用么?我的每次都会提示音乐文件不存在,我复制音乐url到浏览器也显示找不到文件,说明插件里获得的url是不正确的.请问如何解决?是不是网易云音乐API又改了?

关于配置部分说明的开机启动部分

由于开机时某些组件的加载时间原因,直接在rc.local按文档写入内容可能存在唤醒失效(只有启动语音,扫面微信和语音唤醒均无反应)的情况。建议修改说明在前面增加 sleep 5。

另外,启动树莓派的部分最好把绝对路径也加上……严谨严谨……

开机教程中创建软链接部分存在问题

开机教程中创建软链接部分存在问题。

经测试,创建的软链接仅包含软链接本身,不含其中任何文件。打开软链接后ls -ln显示没有任何东西。因此会导致sudo启动失败。本人确定输入的指令与教程完全相同。

推测是root目录默认权限有问题。
尝试过用root身份对/root目录进行chmod 777操作,照样不好使。
后来,本人用root身份 rm -rf /root,然后重新mkdir /root,再重新建立软链接,成功启动叮当,软链接中也出现了对应文件。重建后的root文件夹权限为:drwxr-xr-x。之前的root权限未做记录。

本人初步接触Linux,水平实在有限,烦请进行测试,完善教程。

在Ubuntu Touch上会会导致重启

想在Ubuntu Touch 上运行这个项目,完全按照手动安装的步骤来的,中途也没有出错。
python dingdang.py之后,ubuntu touch就死机重启了。。。

phablet@ubuntu-phablet:~/dingdang$ python dingdang.py



[root@localhost wei]#

系统日志什么也没记录下来,请问有没有可能找到原因?

只要日志出现“[DEBUG] sync_check: -1 -1”,就会发生识别开始与停止时间难以把握。

只要日志出现“[DEBUG] sync_check: -1 -1”,就会发生识别开始与停止时间难以把握,基本录不上。
运气好能赶上两个字,不好的话一个字都识别不上,而且还不一定慢多少或者快多少……时间实在难以把握。

我不太懂这个……但是有没有可能是将“滴滴”音和录音的开始次序调换之后,其他有关的代码没有同步修改……?我记得之前出现这个不会出现这种情况。

比如……录音与播放滴滴音的校正offset应该由-1秒改为0或者+1秒之类的……?

还有,个人感觉目前的识别停止时间比较短促……现在的状态是“嘿叮当”,“滴滴”直接就“嘟嘟”了……必须在听到“滴滴”的时候说而不是在“滴滴”停止的时候说。建议在群里发个投票,看看用不用+1s……

按照教程安装之后运行出错了

小白一个,按照教程里面的步骤安装好配置好之后运行出错了,错误如下:

ERROR:root:Error occured!
Traceback (most recent call last):
File "dingdang.py", line 179, in
app = Dingdang()
File "dingdang.py", line 91, in init
self.config = yaml.safe_load(f)
File "/usr/local/lib/python2.7/dist-packages/yaml/init.py", line 93, in safe_load
return load(stream, SafeLoader)
File "/usr/local/lib/python2.7/dist-packages/yaml/init.py", line 71, in load
return loader.get_single_data()
File "/usr/local/lib/python2.7/dist-packages/yaml/constructor.py", line 37, in get_single_data
node = self.get_single_node()
File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 36, in get_single_node
document = self.compose_document()
File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 55, in compose_document
node = self.compose_node(None, None)
File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 84, in compose_node
node = self.compose_mapping_node(anchor)
File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 127, in compose_mapping_node
while not self.check_event(MappingEndEvent):
File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line 98, in check_event
self.current_event = self.state()
File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line 428, in parse_block_mapping_key
if self.check_token(KeyToken):
File "/usr/local/lib/python2.7/dist-packages/yaml/scanner.py", line 116, in check_token
self.fetch_more_tokens()
File "/usr/local/lib/python2.7/dist-packages/yaml/scanner.py", line 159, in fetch_more_tokens
self.stale_possible_simple_keys()
File "/usr/local/lib/python2.7/dist-packages/yaml/scanner.py", line 289, in stale_possible_simple_keys
"could not found expected ':'", self.get_mark())
ScannerError: while scanning a simple key
in "/home/pi/.dingdang/profile.yml", line 44, column 1
could not found expected ':'
in "/home/pi/.dingdang/profile.yml", line 47, column 1

唤醒后识别不到指令 报 "Nothing has been said or transcribed"

hi, 请教下, 最新镜像烧录, 用的树莓派2+ PS3 Eye + AUX 3.5 口外接音箱。 录音测试正常,可以唤醒,但是无法识别指令, 报 "Nothing has been said or transcribed"。
百度语音API用自带的和我自己申请的都试过,效果一样。
请指教, 谢谢。

源码安装完,能听到提示语,无法接受命令。

pi@raspberrypi:~/dingdang$ python dingdang.py
/usr/local/lib/python2.7/dist-packages/urllib3/contrib/socks.py:37: DependencyWarning: SOCKS support in urllib3 requires the installation of optional dependencies: specifically, PySocks. For more information, see https://urllib3.readthedocs.io/en/latest/contrib.html#socks-proxies
DependencyWarning



Failed to create secure directory (/run/user/1000/pulse): Permission denied
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

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

镜像中系统源替换不彻底

只替换了raspbian源,没有替换raspi源(这个源貌似是Debian系统已经抛弃但是Raspbian还在使用的软件包的源,据观察,阿里云上没有这一目录,只有ustc有……):
Quote:
修改/etc/apt/sources.list.d/raspi.list为以下内容:
deb https://mirrors.ustc.edu.cn/archive.raspberrypi.org/ jessie main ui

(经个人测试……感觉ustc的速度比阿里云快……)
Quote:
编辑/etc/apt/sources.list文件。删除原文件所有内容,用以下内容取代:
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ jessie main non-free contrib
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ jessie main non-free contrib

location of phonetisaurus-g2p is wrong

sudo cp ~/phonetisaurus-0.7.8/phonetisaurus-g2p /usr/local/bin/phonetisaurus-g2p
should be changed to
sudo cp ~/is2013-conversion/bin/phonetisaurus-g2p /usr/local/bin/phonetisaurus-g2p

使用PocketSphinx设置中文唤醒词

目前叮当设置中文唤醒词的方案是

  1. 编写 keyword.txt文件,包含两个全拼唤醒词。
  2. Imtool上传keyword.txt生成字典文件和语言模型文件。
  3. 使用编译好的FST模型g014b2b和随PocketSphinx安装到系统里的英文hmm(隐马尔可夫声学模型)hub4wsj_sc_8k,进行识别。

这种方案利用中文全拼,通过Imtool得到英文音素,利用英文的模型去识别,得到的识别效果还是可以的,但并不是真正的中文唤醒词方案。其实也是自带中文hmm的,即tdt_sc_8k,可以利用它设置真正的中文唤醒词。具体步骤其实和设置英文(全拼)唤醒词的差不多。

  1. profile.yml里面robot_name可以直接设置中文,比如"叮当", 编写 keyword.txt文件,包含两个中文唤醒词,比如"叮当"和"小梅"。
  2. Imtool上传keyword.txt生成字典文件和语言模型文件。然而由于目前Imtool不支持汉字,所以我们只能得到语言模型文件,字典文件里面没有生成相应的音素。所以我们需要手动加入音素信息。
  3. 检查/usr/share/pocketsphinx/model/hmm/里有没有zh文件夹,检查/usr/share/pocketsphinx/model/lm/里有没有zh_CN文件夹,没有的话,到PocketSphinx的源码目录下的model文件夹里把相应的文件夹copy过去。
  4. 由于Imtool生成的dictionary文件没有音素信息,打开/usr/share/pocketsphinx/model/lm/zh_CN/mandarin_notone.dic文件,从里面找到你设置的每个中文唤醒词的相应的音素,没有词组就找相同的字或者同音字,手动完善dictionary的音素信息,比如叮当的音素是"d ing d ang"(注意空格)。
  5. 将dictionary和languagemodel放到相应位置。
  6. profile.yml里面把hmm_dir指向中文hmm:'/usr/share/pocketsphinx/model/hmm/zh/tdt_sc_8k'

这样就能享用真正的中文唤醒词了,不过我在试验中识别返回的结果是gbk编码的汉字,可能需要转换下。至于识别效果,我并没有对两种方案做非常详细的对比,普通话标准的话,可能后者好点?其实不管是全拼方式还是汉字方式,选择一个合适的唤醒词更重要,至于如何挑选出合适的唤醒词,这就需要不断尝试了。另外想提高识别率,还可以用自己的声音改进或者说适配当前的声学模型,有兴趣的同学可以尝试一下。

Wiki开机教程 创建软链接部分 存在问题

经测试,使用 sudo ln -s /home/pi/.dingdang /root/.dingdang 创建软链接,其实际位置位于 /root/.dingdang/.dingdang 。而要建立位于 /root 的软链接,应该使用 sudo ln -s /home/pi/.dingdang /root/ (注意第二个root后面的/不能省略)。

请验证问题是否存在。
(我误删了/root之后重建软链接时发现的这个问题……)

启动后报错:TypeError: argument of type 'NoneType' is not iterable

安装的镜像是8.13版本,
启动后出现以下问题:
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
INFO:client.stt:PocketSphinx 识别到了:[None]
Traceback (most recent call last):
File "dingdang.py", line 190, in
app.run()
File "dingdang.py", line 156, in run
conversation.handleForever()
File "/home/pi/dingdang/client/conversation.py", line 64, in handleForever
threshold, transcribed = self.mic.passiveListen(self.persona)
File "/home/pi/dingdang/client/mic.py", line 245, in passiveListen
if any(PERSONA in phrase for phrase in transcribed):
File "/home/pi/dingdang/client/mic.py", line 245, in
if any(PERSONA in phrase for phrase in transcribed):
TypeError: argument of type 'NoneType' is not iterable

请教该如何解决,本人小白一枚

考虑到rc.local以root用户身份执行的权限问题,建议修改开机启动教程

采用如下方法,可以免去建立软链接,同时解决rc.local以root用户身份执行的权限问题(如网易云音乐因缺乏写权限而无法使用)。

在 /home/pi/.config 下找到autostart的文件夹。在该文件夹下创建一个空文件,文件名自拟,后缀必须是desktop,如:dingdang.desktop。
用记事本打开该文件,修改文件内容如下并保存:

[Desktop Entry]
Name=Dingdang
Comment=Dingdang Robot
Exec=sudo python /home/pi/dingdang/dingdang.py
Icon=/home/pi/python_games/4row_black.png
Terminal=false
MultipleArgs=false
Type=Application
Categories=Application;Development;
StartupNotify=true

Name、Comment、Icon 可以自定,分别表示启动项的名称、备注和图标。Exec 表示调用的指令,和在终端输入运行脚本的指令格式一致。为了使叮当的重新启动插件可用(重新启动插件要求root权限),在Exec部分增加了sudo。如果希望叮当在开机时在终端中启动,可以修改exec为:sudo lxterminal -e "python /home/pi/dingdang/dingdang.py"

重新启动系统后将会自动以默认用户(pi)身份启动叮当。

(但是这样貌似就没有办法 sleep 5 了,在本人的十几次测试中,有两次发生叮当无法正常播放语音。如果有办法sleep,最好是想办法加上。个人考虑可以在rc.local中sleep,在这个里面启动。但是不知道rc.local的sleep是否能有效改善这一情况,还有待观察和测试。)

参考链接:http://blog.csdn.net/A_lPha/article/details/53515943

Cannot connect to server socket err

`
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
`

按照手动安装指南安装失败

由于我不擅长这个,现在按照wiki手动安装指南卡在了编译安装openFast这里,报错如下,特向各位大大请教下

raspberry pi 3B
OS: Raspbian 9.1 stretch
Kernel: armv7l Linux 4.9.41-v7+


libtool: install: /usr/bin/install -c .libs/libfst.lai /usr/local/lib/libfst.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/home/pi/Downloads/openfst-1.3.4/src/lib'
make[2]: Leaving directory '/home/pi/Downloads/openfst-1.3.4/src/lib'
Making install in script
make[2]: Entering directory '/home/pi/Downloads/openfst-1.3.4/src/script'
/bin/bash ../../libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H   -I./../include    -g -O2 -MT text-io.lo -MD -MP -MF .deps/text-io.Tpo -c -o text-io.lo text-io.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I./../include -g -O2 -MT text-io.lo -MD -MP -MF .deps/text-io.Tpo -c text-io.cc  -fPIC -DPIC -o .libs/text-io.o
text-io.cc: In function 'bool fst::script::WritePotentials(const string&, const std::vector<fst::script::WeightClass>&)':
text-io.cc:87:15: error: cannot convert 'std::ostream {aka std::basic_ostream<char>}' to 'bool' in initialization
   bool ret = *strm;
               ^~~~
Makefile:388: recipe for target 'text-io.lo' failed
make[2]: *** [text-io.lo] Error 1
make[2]: Leaving directory '/home/pi/Downloads/openfst-1.3.4/src/script'
Makefile:260: recipe for target 'install-recursive' failed
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory '/home/pi/Downloads/openfst-1.3.4/src'
Makefile:312: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1

最新版本的robot.py存在问题。

今天更新过emotibot之后的问题。
robot.py文件中第167行里那个末有“[0]”,删去才能正常调用Emotibot。

啊对了……另外建议修缮一下操作的语音提示。比如在“即将播放”后面加个冒号以及在“歌手-歌名”之间增加个逗号,增加个停顿之类的……这些细节对体验而言很重要啊……

(我没研究明白Git,要不我就弄pull request了……)

logo征集

征集叮当机器人的logo,将被用在项目主页、QQ群头像、论坛等多处。

欢迎贡献~~~

请教dalao

运行 dingdang.py 抛出异常

Traceback (most recent call last):
  File "dingdang.py", line 12, in <module>
    from client import stt
  File "/home/sparkle/dingdang-robot/client/stt.py", line 22, in <module>
    from requests.packages.urllib3.exceptions import InsecureRequestWarning
ImportError: cannot import name InsecureRequestWarning

用 pip 安装 requests 结果一样

另外编译安装 Phonetisaurus 时,make各种报错编译失败

均严格按照文档操作

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.