File "HJ.py", line 20, in yuyinhx
if any(['好'.encode("utf-8")in meg,'你'.encode("utf-8")in meg,"你好".encode("utf-8")in meg,"您".encode("utf-8")in meg]):
TypeError: 'in <string>' requires string as left operand, not bytes
代码
def yuyinhx():
os.system('arecord -D "plughw:1" -f S16_LE -r 16000 -d 3 /home/pi/Desktop/yyhx.wav')
meg =yuyinshibie.asr_main("/home/pi/Desktop/yyhx.wav",token)
if any(['好'.encode("utf-8")in meg,'你'.encode("utf-8")in meg,"你好".encode("utf-8")in meg,"您".encode("utf-8")in meg]):
f=open('/home/pi/Desktop/yyhx.wav','wb')
f.close()
url="http://tsn.baidu.com/text2audio?tex=我来啦&lan=zh&cuid=B8-27-EB-BA-24-14&ctp=1&tok="+token+"&per=3"
os.system('mpg123 "%s"'%url)
global flag
flag = True