
Security News
Node.js Homepage Adds Paid Support Link, Prompting Contributor Pushback
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
小爱音箱自定义文本朗读。
不止是 TTS
npm i xiaoai-tts
const XiaoAi = require('xiaoai-tts')
// 输入小米账户名,密码
const client = new XiaoAi('fish', '123456')
// 朗读文本
client.say('你好,我是小爱')
username
{String}
小米账户用户名password
{String}
账户密码使用小米账户登录小爱音箱
session
{Object}
Session 信息
userId
{String}
serviceToken
{String}
使用 Session
登录。
使用小米账户登录后,调用 connect()
返回用户登录信息;
Session
可持久化保存,实例化 XiaoAi
时可直接传入:
const fs = require('fs')
let client = null
try {
// 尝试读取本地 Session 信息
const Session = fs.readFileSync('~/xiaoai/session', { encoding: 'utf8' })
// 通过 Session 登录
client = new XiaoAi(JSON.parse(Session))
} catch (e) {
client = new XiaoAi('fish', '123456')
const Session = await client.connect()
// 将 Session 储存到本地
fs.writeFileSync('~/xiaoai/session', JSON.stringify(Session))
}
XiaoAi 实例对象
text
{String}
文本信息{Promise<Response>}
朗读指定文本,返回接口调用结果
client.say('你好,我是小爱')
name
{String}
设备名称(别名){Promise<Promise<Object[] | Object | null>}
设备信息获取在线设备列表
// 获取所有在线设备
const onlineDevices = await client.getDevice()
// 获取单个设备,未找到时返回 null
const roomDevice = await client.getDevice('卧室小爱')
deviceId
{String}
设备 id切换指定设备。xiaomi-tts
实例化后默认使用 getDevice()
方法返回的第一个设备,可使用此方法切换为指定设备。
const roomDevice = await client.getDevice('卧室小爱')
// 使用“卧室小爱”
client.useDevice(roomDevice.deviceID)
client.say('你好,我是卧室的小爱')
{Promise<Session>}
session 信息
Session.userId
{String}
Session.serviceToken
{String}
获取 Session
信息
const Session = await client.connect()
{Promise<Response>}
测试连通性
client.test()
volume
{Number}
音量值{Promise<Response>}
设置音量
client.setVolume(30)
{Promise<Number>}
音量值获取音量
const volume = await client.getVolume()
{Promise<Response>}
调高音量,幅度 5
{Promise<Response>}
调低音量,幅度 5
{Promise<Response>}
状态信息获取设备运行状态
{Promise<Response>}
继续播放
{Promise<Response>}
暂停播放
{Promise<Response>}
切换播放状态(播放/暂停)
{Promise<Response>}
播放上一曲
{Promise<Response>}
播放下一曲
songId
{String}
歌曲 id{Promise<Response | null>}
歌曲信息查询歌曲信息
const songInfo = await client.getSongInfo('7519904358300484678')
listId
{String}
歌单 id{Promise<Object[]>}
歌曲信息获取用户自建歌单,当指定 listId
时,将返回目标歌单内的歌曲列表
// 获取歌单列表
const myPlaylist = await client.getMyPlaylist()
// 获取歌单内的歌曲列表
const songList = await client.getMyPlaylist('337361232731772372')
url
{String}
音频地址{Promise<Response>}
播放在线音频
FAQs
小爱音箱 TTS
The npm package xiaoai-tts receives a total of 2 weekly downloads. As such, xiaoai-tts popularity was classified as not popular.
We found that xiaoai-tts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
Research
Security News
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.