2 Star 12 Fork 5

mjTree/语音聊天机器人

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wechatRobot.py 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
mjTree 提交于 2018-03-31 18:16 +08:00 . 智障语音机器人
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from Recorder import recorder as rd
from SpeechRecognition import speechRecognition as sR
from RobotInteraction import robotInteraction as rI
from SpeechSynthesis import speechSynthesis as sS
"""
function: 接收用户语音,存储为wav音频文件
"""
def get_UserAudio():
rd.recording()
"""
function: 将音频文件转成文字信息
return: 转化成功后的文字信息
"""
def audio_word():
filename = "say_voice.wav"
userInfo = sR.speechRecognition(filename)
return userInfo
"""
function: 接收用户对话,返回相应对话
parameter: userInfo 用户描述的言语
return: 反馈用户的交互文字信息
"""
def getInteractiveInfo(userInfo):
feedbackInfo = rI.get_response(userInfo)
return feedbackInfo
"""
function: 接收用户语音,转成文字
return: 用户的言语文字
"""
def AcceptDialogue():
phrase = speech.input()
return phrase.encode('gb2312')
"""
function: 接收文字,转成语音播出
parameter: 反馈用户的言语
"""
def speechSyn(feedbackInfo):
sS.synthesisInfo(feedbackInfo)
sS.voiceBroadcast('hello.wav')
"""
function: 借用高级接口实现语音聊天
"""
def main():
while True:
get_UserAudio()
userInfo = audio_word()
print(userInfo)
feedbackInfo = getInteractiveInfo(userInfo)
print(feedbackInfo)
speechSyn(feedbackInfo)
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mjTree/voice_chat_robot.git
git@gitee.com:mjTree/voice_chat_robot.git
mjTree
voice_chat_robot
语音聊天机器人
master

搜索帮助