树莓派redis

import redis
from aip import AipSpeech
import os

pool=redis.ConnectionPool(host='',port=6379,db=1)
r=redis.StrictRedis(connection_pool=pool)

APP_ID = '18160517'  # 引号之间填写之前在ai平台上获得的参数
API_KEY = 'kuAvCtKlGhtjhcxbkcIMQyxz'  # 如上
SECRET_KEY = 'D5HulHKoEn1jMx5hR4OCUZP0H5FkO7eG'  # 如上

client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
while True:
	sign=r.lrange("sign-tx2",0,-1)
	if sign:
		words=r.rpop("sign-tx2").decode()
		lan=words
		result = client.synthesis(lan, 'zh', 1, {'vol': 5, 'per': 4, 'spd': 5})
		# 识别正确返回语音二进制 错误则返回dict 参照下面错误码
if not isinstance(result, dict):
    with open('/home/pi/Music/aui1.mp3', 'wb') as f:
        f.write(result)
os.system('mpg123 /home/pi/Music/aui1.mp3')        
发布了225 篇原创文章 · 获赞 9 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_41834780/article/details/103969021