1

os : windows 10 64bits python: 3.7.3(anaconda)

# -*- coding: utf-8 -*-
from aip import AipSpeech

APP_ID = ''
API_KEY = 'xxx'
SECRET_KEY = 'yyy'

client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)


def get_file_content(filePath):
    with open(filePath, 'rb') as fp:
        return fp.read()


# call "client.asr(get_file_content('01.wav'), 'wav', 16000)" will throw exception    
results = client.asr(get_file_content('01.wav'), 'wav', 16000)

print(results)

Error messages

"""
    Traceback (most recent call last):
      File "baidu_speech_reg_api.py", line 18, in <module>
        results = client.asr(get_file_content('01.wav'), 'wav', 16000)
      File "C:\Users\yyyy\Anaconda3\envs\pyside2\lib\site-packages\aip\speech.py", line 78, in asr
        return self._request(self.__asrUrl, data)
      File "C:\Users\yyyy\Anaconda3\envs\pyside2\lib\site-packages\aip\base.py", line 90, in _request
        params = self._getParams(authObj)
      File "C:\Users\yyyy\Anaconda3\envs\pyside2\lib\site-packages\aip\base.py", line 190, in _getParams
        params['access_token'] = authObj['access_token']
    KeyError: 'access_token'
"""

I can use the same keys for ocr and image classification, but speech recognition always fail.

StereoMatching
  • 4,971
  • 6
  • 38
  • 70

0 Answers0