百度AI
1.语音合成
1.登录百度AI平台
选择控制台
参考技术文档选择python SDK
pip install baidu-aip
from aip import AipSpeech
APP_ID = '2191211'
API_KEY = 'tQ1f7pryTnMjQMfuYGL8'
SECRET_KEY = 'M70i1KwVfYgKZLY0pvl3LKGtTYg'
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
result = client.synthesis('先帝创业未半而中道崩殂', 'zh', 1,
{
'vol': 5,
"spd": 4,
"pit": 6,
"per": 4
})
# 识别正确返回语音二进制 错误则返回dict 参照下面错误码
if not isinstance(result, dict):
with open('aui2do.mp3', 'wb') as f:
f.write(result)
else:
print(result)
2.语音识别
from aip import AipSpeech
APP_ID = '21411'
API_KEY = 'tQ1f7prynKMjQMfuYGL8'
SECRET_KEY = 'M70i1KwVfYgKZpEnGvl3LKGtTYg'
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
# 读取文件
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
# 识别本地文件
res = client.asr(get_file_content('wyn.m4a.pcm'), 'pcm', 16000, {
'dev_pid': 1537,
})
print(res['result'][0])
3.智障对话
1.low版本
from aip import AipSpeech
import os
APP_ID = '21911'
API_KEY = 'tQ1f7pryTnKMQMfuYGL8'
SECRET_KEY = 'M70i1KgKZYr0pE5nGvl3LKGtTYg'
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
# 读取文件
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
# 识别本地文件
res = client.asr(get_file_content('wyn.m4a.pcm'), 'pcm', 16000, {
'dev_pid': 1537,
})
Q = res['result'][0]
A = "我不知道"
if Q == "你的名字叫什么?":
A = "zbb"
result = client.synthesis(A, 'zh', 1,
{
'vol': 5,
"spd": 4,
"pit": 6,
"per": 4
})
if not isinstance(result, dict):
with open('aui2do.mp3', 'wb') as f:
f.write(result)
else:
print(result)
os.system("aui2do.mp3")
2.升级版
自然语言处理
from aip import AipSpeech
from aip import AipNlp
import os
APP_ID = '22411'
API_KEY = 'tQ1f7pryTnd8MfuYGL8'
SECRET_KEY = 'M70i1KwVfYK0pE5nGvl3LKGtTYg'
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
nlp_client = AipNlp(APP_ID, API_KEY, SECRET_KEY)
# 读取文件
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
# 识别本地文件
res = client.asr(get_file_content('wyn.m4a.pcm'), 'pcm', 16000, {
'dev_pid': 1537,
})
Q = res['result'][0]
A = "我是你爸爸"
if nlp_client.simnet(Q, "你的名字叫什么?")['score'] > 0.6:
A = "你是我儿子"
result = client.synthesis(A, 'zh', 1,
{
'vol': 5,
"spd": 4,
"pit": 6,
"per": 4
})
if not isinstance(result, dict):
with open('aui2do.mp3', 'wb') as f:
f.write(result)
else:
print(result)
os.system("aui2do.mp3")
3.加强版
问答机器人 -图灵机器人
import requests
res = requests.post(url='http://openapi.tuling123.com/openapi/api/v2', json={
"reqType": 0,
"perception": {
"inputText": {
"text": "青岛的天气"
},
},
"userInfo": {
"apiKey": "9ea379299a91354e0fe979ad",
"userId": "6542"
}
})
print(res.json()['results'][0]['values']['text'])
#青岛:周二 08月11日,多云转小雨 南风,最低气温25度,最高气温28度。~
4.进化版
from aip import AipSpeech
from aip import AipNlp
import os
import requests
APP_ID = '212411'
API_KEY = 'tQ1f7prTnd8jQMfuYGL8'
SECRET_KEY = 'M70i1KwVfYr0'
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
nlp_client = AipNlp(APP_ID, API_KEY, SECRET_KEY)
# 读取文件
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
# 识别本地文件
res = client.asr(get_file_content('wyn.m4a.pcm'), 'pcm', 16000, {
'dev_pid': 1537,
})
Q = res['result'][0]
if nlp_client.simnet(Q, "附近的酒单?")['score'] > 0.6:
A = "你是我儿子"
else:
res = requests.post(url='http://openapi.tuling123.com/openapi/api/v2', json={
"reqType": 0,
"perception": {
"inputText": {
"text": Q
},
},
"userInfo": {
"apiKey": "9ea379299354e979ad",
"userId": "654562"
}
})
A = res.json()['results'][0]['values']['text']
result = client.synthesis(A, 'zh', 1,
{
'vol': 5,
"spd": 4,
"pit": 6,
"per": 4
})
if not isinstance(result, dict):
with open('aui2do.mp3', 'wb') as f:
f.write(result)
else:
print(result)
os.system("aui2do.mp3")
5.究极版
科大讯飞 语音最强没有之一(当然图片识别啥的好烂。。。)
热爱技术,享受生活,感谢推荐!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求