Falsk Basic speech recognition and speech synthesis ()

Source: Internet
Author: User

First search http://ai.baidu.com/to enter the official website.

Drop down to find Baidu voice:

Then create a voice app:

After you manage your app:

Speech synthesis:

Then create a new py file:

 fromAipImportaipspeechapp_id='14454183'Api_key='TXNUGCISENVEB93I70ESWWB4'Secret_key='Dzdok3dcueuxe28atfgioqzxvd91bmqu'Client=Aipspeech (app_id, Api_key, Secret_key) Res= Client.synthesis ('If I love you', options={    "Vol.": 8,    "Pit": 8,    "SPD": 5,    "per": 4}) with open ("Audio.mp3",'WB') as F:f.write (res)

Speech recognition:

To save an audio file locally, create a new py file:

 fromAipImportAipspeechImportosapp_id='14454183'Api_key='TXNUGCISENVEB93I70ESWWB4'Secret_key='Dzdok3dcueuxe28atfgioqzxvd91bmqu'Client=Aipspeech (app_id, Api_key, Secret_key)defget_file_content (filePath):" "because only PCM-formatted audio is recognized, the MP3 format is converted to PCM format using FFmpeg" "Cmd_str="ffmpeg-y-i {0}-acodec pcm_s16le-f s16le-ac 1-ar 16000 {0}.pcm". Format (FilePath) Os.system (CMD_STR) with open ("%S.PCM"% (FilePath),'RB') as F:returnF.read () Res= Client.asr (Speech=get_file_content ("Audio.mp3"), options={    "Dev_pid": 1536,})Print(RES)

Remember to place the bin directory in the Ffpeg in the system environment variable, and then restart Pycharn.

Then we write a demo:

Falsk Basic speech recognition and speech synthesis ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.