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




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




  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 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:

Recommended Today

Select the text and add a style

<!DOCTYPE html> <html lang=”en”> <head> <meta charset=”utf-8″> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <meta name=”viewport” content=”width=device-width,initial-scale=1.0″> <style>{ border: 3px solid rgb(32, 156, 238); background-color: rgb(32, 156, 238); }{ border: 3px solid rgb(255, 51, 51); background-color: rgb(255, 51, 51); } .tag{ color: #fff; border-radius: 5px; font-style: normal; } .tag > .delete{ / margin-left: 5px; / background-color: rgba(10,10,10,.2); […]