语音转文本SSL问题

时间:2019-01-02 18:44:40

标签: ssl

我正在尝试运行一个非常简单的python代码以进行文本语音转换,但是由于SSL失败。

代码:

url = 'https://northeurope.api.cognitive.microsoft.com/sts/v1.0/issueToken'
headers = {
        'Ocp-Apim-Subscription-Key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'
    }
r = requests.post(url, headers=headers)
token = r.content
print(token)



url = 'https://northeurope.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US&format=simple'
headers = {
        'Accept': 'application/json',
        'Ocp-Apim-Subscription-Key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        'Transfer-Encoding': 'chunked',
        'Content-type': 'audio/wav; codec=audio/pcm; samplerate=16000',
        'Authorization': 'Bearer {0}'.format(token)
    }
r = requests.post(url, headers=headers, data=stream_audio_file('/home/nbuser/1.wav'))
print(r.content)

产生以下错误:

ConnectionError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'unknown protocol')],)",)

0 个答案:

没有答案