How to change the gender of Uncle Xiaojiao? Python implements the function of voice transformer

Time:2020-4-12

 

Preface

The text and pictures of this article are from the Internet, only for learning and communication, not for any commercial purpose. The copyright belongs to the original author. If you have any questions, please contact us in time for handling.

By Joe Coe

PS: if you need Python learning materials, you can click the link below to get http://t.cn/a6zvjdun

 

 

 

  1. Log in to Baidu al development platform
  2. Select voice synthesis on the console
  3. Create application
  4. Fill in application information
  5. Get in the application list (appid, API key, secret key)

6. Install pythonsdk

The python SDK can be installed and used in the following ways:

  • If PIP has been installed, execute PIP install Baidu AIP.
  • If setuptools is installed, execute Python setup.py install.

7. Write code

from aip import AipSpeech
 "" "your appid AK SK" ""
 App 'id =' your app ID '
 Api_key = 'your API key'
 Secret_key = 'your secret key'
 client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
 Result = client. Synthesis ('Hello Baidu ',' zh ', 1{
 'vol': 5,
})
#If the recognition is correct and the binary error of voice is returned, then the dict will be returned with reference to the following error code
if not isinstance(result, dict):
 with open('auido.mp3', 'wb') as f:
 f.write(result)