API文档
记得进入“快速开始”获取token
使用中发现问题,请进入“联系我们”与客服沟通,一般会得到快速解决
01
文字转语音(TTS)
声音自然优美,音质远超开源模型,已稳定运行15年+
//TTS nodejs sample
async function ttsPostRequest(url,token,bodyData) {
const headers = {
'Content-Type': 'application/json',
'X-Mishu-Token': token
};
try {
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(bodyData)
});
if (!response.ok) {
throw new Error(`Server error: ${response.status}`);
}
const jsonResult = await response.json();
return jsonResult;
} catch (error) {
console.error('Request failed:', error.message);
return null;
}
}
//call
const url = "https://api.mishubaobao.com/v1/api/tts";
const token = 'your token';//Change to your own token
const bodyData = {
text: "hello,world",
speed: 1.0,
pitch: 0,
style: "whisper",
voice: "zh-CN-XiaoxiaoNeural"
};
const result = await ttsPostRequest(url,token,bodyData);
console.log('Request result:', result);参数说明:
- token: 类型文本,用户密钥,请到“快速开始”获取
- text: 类型文本,TTS的文本,最多500字(包含各种符号),插入格式[pause:1.5s],表示停顿1.5秒
- speed: 类型数字,语速调节,取值范围0.3-3.0,默认1.0
- pitch: 类型数字,音调高低,取值范围-50-50,默认0
- voice: 类型文本,发音人模型,默认zh-CN-XiaoxiaoNeural
- style: 类型文本,语音风格,默认general
- zh-CN-XiaoxiaoNeural
- general
//TTS Response
{
"code": 0,
"data": {
"amount": 5,
"duration": 3.2,
"textLen": 14,
"url": "http://64.64.228.242:3000/v1/download?file=202606/wj8stz00t.mp3"
},
"msg": "成功"
}参数说明:
- code: 0:成功,1:密钥不匹配,2:文本空或太多,3:语速不匹配,4:音调不匹配,5:余额不足,6:合作方TTS服务器错误
- amount: 金额(分)
- duration:语音时长(秒),1位小数点
- textLen: 文本长度
- url: 音频下载网址,定期清理
- msg: 对code含义的文字说明
02
电话/App语音通知
拨打手机,播放语音文件,提供通知、提醒、祝福、叫起床。telegram、whatsapp等方式待接入
//Voice Notification nodejs sample
async function audioCallRequest(url,token,bodyData) {
const headers = {
'Content-Type': 'application/json',
'X-Mishu-Token': token
};
try {
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(bodyData)
});
if (!response.ok) {
throw new Error(`Server error: ${response.status}`);
}
const jsonResult = await response.json();
return jsonResult;
} catch (error) {
console.error('Request failed:', error.message);
return null;
}
}
//call
const url = "https://api.mishubaobao.com/v1/api/audioCall";
const token = 'your token';//Change to your own token
const bodyData = {
"mobi":"15900004466",//Change to your own mobile
"startDate":1780888000,
"url" :"https://help88.com/m/25.mp3"
};
const result = await audioCallRequest(url,token,bodyData);
console.log('Request result:', result);参数说明:
- startDate: 类型数字,开始拨打时间戳秒,默认0立刻马上
- trytimes: 类型数字,第一次拨打失败后尝试拨打次数,默认0,最大3,每次间隔60秒
- appType: 类型数字,通话方式,默认固定1:电话,其他wx,whatsapp等暂未开放
- url: 类型文本,音频文件网址,必须是mp3类型
- mobi: 类型文本,11位手机号码,目前只开放大陆手机号码
- https://help88.com/m/25.mp3
//Voice Notification Response
{
"code": 0,
"msg": "提交成功"
}参数说明:
- code: 0:提交成功,1:密钥不匹配,2:appType错误,3:手机号码不正确,4:开始拨打时间戳秒不正确,5:mp3网址不正确,6:余额不足,7:服务器错误
- msg: 对code含义的文字说明,微信小程序“秘书宝宝”可查看拨打状态”
