Exemple #1
0
# -*- coding:utf-8 -*-
from ais_sdk.asr_bgm import asr_bgm_aksk
from ais_sdk.utils import init_global_env

if __name__ == '__main__':
    #
    # access asr, asr_bgm,post data by ak,sk
    #
    app_key = '*************'
    app_secret = '************'
    init_global_env(region='cn-north-1')

    # The OBS link needs to be consistent with the region, and the OBS resources of different regions are not shared
    demo_data_url = 'https://obs-test-llg.obs.cn-north-1.myhuaweicloud.com/bgm_recognition'
    result = asr_bgm_aksk(app_key, app_secret, demo_data_url)
    print result
Exemple #2
0
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.asr_sentence import asr_sentence
from ais_sdk.utils import init_global_env

if __name__ == '__main__':
    # Services currently support North China-Beijing 1 (cn-north-1)
    init_global_env('cn-north-1')

    #
    # access asr, asr_sentence,post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use

    demo_data_url = 'https://obs-ch-sdk-sample.obs.cn-north-1.myhwclouds.com/asr-sentence.wav'
    token = get_token(user_name, password, account_name)

    # call interface use the url
    result = asr_sentence(token, '', demo_data_url, 'wav', '16k')
    print(result)

    # call interface use the file
    result = asr_sentence(token, encode_to_base64('data/asr-sentence.wav'), '',
                          'wav', '16k')
    print(result)
# -*- coding:utf-8 -*-
from ais_sdk.gettoken import get_token
from ais_sdk.utils import encode_to_base64
from ais_sdk.celebrity_recognition import celebrity_recognition
from ais_sdk.utils import init_global_env

if __name__ == '__main__':
    #
    # access image tagging , post data by token
    #
    user_name = '******'
    password = '******'
    account_name = '******'  # the same as user_name in commonly use
    init_global_env(region='ap-southeast-1')

    # The OBS link needs to be consistent with the region, and the OBS resources of different regions are not shared
    demo_data_url = 'https://ais-sample-data.obs.cn-north-1.myhuaweicloud.com/celebrity-recognition.jpg'

    token = get_token(user_name, password, account_name)

    # call interface use the url
    result = celebrity_recognition(token, "", demo_data_url, 0.48)
    print(result)

    # call interface use the file
    result = celebrity_recognition(
        token, encode_to_base64('data/celebrity-recognition.jpg'), '', 0.48)
    print(result)