DelightRun / PyBaiduYuyin

This project has been deprecated
MIT License
77 stars 38 forks source link

TypeError(repr(o) + " is not JSON serializable") #7

Open alatriste-lee opened 8 years ago

alatriste-lee commented 8 years ago

self.request = Request(url, data = json.dumps(data), headers = {"Content-Type": "application/json"})

json.dumps(data)

makelove commented 8 years ago

也碰到这个问题。 不过我改了代码。百度的post data规格改了。 data = { "format": "pcm",

"lan": self.language,

        "token": self.token,
        "len": len(audio_data.data),
        # "rate": audio_data.rate,
        "rate": 8000,
        "channel" : 1,
        "speech": base64.b64encode(audio_data.data),
        "cuid": '93489083242',
    }

不过出现另外一个问题 with sr.WavFile(WAV_FILE) as source: audio = r.record(source) # read the entire WAV file 读不出数据!!! audio为空!!