1 Star 1 Fork 0

codestar/voice_message

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
billi_win_voice.py 870 Bytes
一键复制 编辑 原始数据 按行查看 历史
codestar 提交于 2021-05-31 17:55 . rename main.py to billi_win_voice.py.
import time
from bilibili_api import live
from bilibili_api import user
import time as t
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty("rate", "100")
engine.setProperty("volume", "1.0")
dm = live.LiveDanmaku(room_display_id="5239322", debug=False, use_wss=True, should_reconnect=True)
def connect():
dm.connect()
@dm.on("DANMU_MSG") # 指定事件名
def on_danmu(msg):
if "info" in str(msg):
info = msg["data"]["info"]
message = str(info[2][1]) + ": " + str(info[1])
print("【弹幕】 from " + message)
# engine.Speak(f"{str(info[2][1])} 说: {str(info[1])}")
# t.sleep(1)
voice = f"{str(info[2][1])} 说: {str(info[1])}"
engine.say(voice)
engine.runAndWait()
if __name__ == '__main__':
connect()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/star574/voice_message.git
git@gitee.com:star574/voice_message.git
star574
voice_message
voice_message
master

搜索帮助