from aip import AipSpeech

""" 你的 APPID AK SK """
APP_ID = ''
API_KEY = ''
SECRET_KEY = ''

words = ['零','一','二','三','四','五','六','七','八','九','十','十','百','千']
obstetrics = ['收缩压', '舒张压', '血压', '高压', '低压', '腹围', '脉搏', '体重', '体温', '宫高', '胎心率', '胎心']
common = ['收缩压一百二十五']
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)

def baidu_api(client,words):
    """发音人选择, 0为女声，1为男声，3为情感合成-度逍遥，4为情感合成-度丫丫，默认为普通女"""

    for word in words:
        for person in [3]:
        # for person in [0, 1, 3, 4]:
            file_name = './baidu/' + word + '_发音人' + str(person) + '.wav'
            result = client.synthesis(word, 'zh', 1, {
                'vol': 7,
                'per':person,
                'aue':6
            })
            if not isinstance(result, dict):
                with open(file_name, 'wb') as f:
                    f.write(result)
        print('Generated by BaiDu API:',word)
    return 0
if __name__ == '__main__':
    baidu_api(client,common)



