python语音转文字 sdk_使用百度云API进行语音转文字(基于python的wav文件转换)...

1 #!/usr/bin/python

2 #-*- coding: UTF-8 -*-

3 from aip importAipSpeech4

5 #从百度AI开放平台创建应用处获取

6 APP_ID = ''

7 API_KEY = ''

8 SECRET_KEY = ''

9

10 client =AipSpeech(APP_ID, API_KEY, SECRET_KEY)11

12 #读取文件

13 defget_file_content(filePath):14 with open(filePath, 'rb') as fp:15 returnfp.read()16

17 #识别本地文件

18 defget_text():19 result = client.asr(get_file_content('record.wav'), 'wav', 16000, {20 'dev_pid': 1536,})21 print(result)22 text = result['result'][0]23 returntext24

25 print(get_text())

你可能感兴趣的:(python语音转文字,sdk)