Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python的Microsoft Bing语音API:无JSON对象_Python_Rest_Microsoft Speech Api - Fatal编程技术网

使用Python的Microsoft Bing语音API:无JSON对象

使用Python的Microsoft Bing语音API:无JSON对象,python,rest,microsoft-speech-api,Python,Rest,Microsoft Speech Api,我正在尝试用Python实现Microsoft Bing语音REST API,我在网上找到了一些代码 我遵循了上面的代码(并更改了密钥和音频文件名),但一直得到以下结果: Traceback (most recent call last): File "/Users/emi/Desktop/proj/taygan tutorial/handler.py", line 55, in <module> handler() File "/Users/emi/Desktop

我正在尝试用Python实现Microsoft Bing语音REST API,我在网上找到了一些代码

我遵循了上面的代码(并更改了密钥和音频文件名),但一直得到以下结果:

Traceback (most recent call last):
  File "/Users/emi/Desktop/proj/taygan tutorial/handler.py", line 55, in <module>
    handler()
  File "/Users/emi/Desktop/proj/taygan tutorial/handler.py", line 15, in handler
    results = get_text(token, YOUR_AUDIO_FILE)
  File "/Users/emi/Desktop/proj/taygan tutorial/handler.py", line 40, in get_text
    results = json.loads(r.content)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
回溯(最近一次呼叫最后一次):
文件“/Users/emi/Desktop/proj/taygan tutorial/handler.py”,第55行,在
handler()
文件“/Users/emi/Desktop/proj/taygan tutorial/handler.py”,handler中的第15行
结果=获取\u文本(令牌,您的\u音频\u文件)
get_文本中的文件“/Users/emi/Desktop/proj/taygan tutorial/handler.py”,第40行
结果=json.loads(r.content)
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/_init__.py”,第338行,加载
返回\u默认\u解码器。解码
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py”,第366行,在decode中
obj,end=self.raw\u decode(s,idx=\u w(s,0.end())
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py”,第384行,原始解码
raise VALUERROR(“无法解码JSON对象”)
ValueError:无法解码任何JSON对象
完全是新手,所以真的不明白发生了什么。谢谢

注意:我也尝试过这段代码
但是我收到了很多错误。

请将您的代码作为文本添加到您的问题中@美元。对不起,我做了!您没有检查http响应代码。您可能会在不知情的情况下收到正文中的错误消息。
Traceback (most recent call last):
  File "/Users/emi/Desktop/proj/taygan tutorial/handler.py", line 55, in <module>
    handler()
  File "/Users/emi/Desktop/proj/taygan tutorial/handler.py", line 15, in handler
    results = get_text(token, YOUR_AUDIO_FILE)
  File "/Users/emi/Desktop/proj/taygan tutorial/handler.py", line 40, in get_text
    results = json.loads(r.content)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded