Skip to main content

xiaoaitts

PyPI PyPI - Python Version PyPI - License GitHub last commit

小爱音箱自定义文本朗读。

不止是 TTS

安装

pip install xiaoaitts

使用

from xiaoaitts import XiaoAi

# 输入小米账户名,密码
client = XiaoAi('fish', '123456')
# 朗读文本
client.say('你好,我是小爱')

API

Class: XiaoAi

XiaoAi(user, password)

  • username 小米账户用户名
  • password 账户密码

使用小米账户登录小爱音箱

instance

XiaoAi 实例对象

say(text)

  • text 文本信息

朗读指定文本,返回接口调用结果

client.say('你好,我是小爱')

get_device(name=None)

  • name 设备名称(别名)
  • Returns: 设备信息

获取在线设备列表

# 获取所有在线设备
online_devices = client.get_device()
# 获取单个设备,未找到时返回 null
room_device = client.get_device('卧室小爱')

use_device(device_id)

  • device_id 设备id

切换指定设备。xiaomitts 实例化后默认使用 get_device() 方法返回的第一个设备,可使用此方法切换为指定设备。

room_device = client.get_device('卧室小爱')
# 使用“卧室小爱”
client.use_device(room_device.get('deviceID'))
client.say('你好,我是卧室的小爱')

test()

测试连通性

client.test()

媒体控制

set_volume(volume)

  • volume 音量值

设置音量

client.set_volume(30)

get_volume()

  • Returns: 音量值

获取音量

volume = client.get_volume()

volume_up()

调高音量,幅度 5

volume_down()

调低音量,幅度 5

get_status()

  • Returns: 状态信息

获取设备运行状态

play()

继续播放

pause()

暂停播放

prev()

播放上一曲

next()

播放下一曲

set_play_loop(type=1)

  • type 0-单曲循环 1-列表循环 3-列表随机

设置循环播放

get_song_info(song_id)

  • song_id 歌曲id
  • Returns: 歌曲信息

查询歌曲信息

song_info = client.get_song_info('7519904358300484678')

get_my_playlist(list_id=None)

  • list_id 歌单id
  • Returns: 歌曲信息

获取用户自建歌单,当指定 list_id 时,将返回目标歌单内的歌曲列表

# 获取歌单列表
my_playlist = client.get_my_playlist()
# 获取歌单内的歌曲列表
song_list = client.get_my_playlist('337361232731772372')

参考链接

Metadata

Release files for xiaoaitts 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xiaoaitts 0.1.1
File Size Uploaded Provenance
xiaoaitts-0.1.1.tar.gz 11.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for xiaoaitts 0.1.1
File Interpreter ABI Platform
xiaoaitts-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.2 kB

Release files / xiaoaitts-0.1.1.tar.gz

Download URL xiaoaitts-0.1.1.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6f07955eb08f4b33bf34413907d61bea1fc0f2b2c1348ba74af01f7ecb02941e
BLAKE2b-256 checksum
How to use checksums
049bb3e5eab3b0cab971839cf701654e17eddbfb0ec9b7e5634c21583abc143e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.10

Release files / xiaoaitts-0.1.1-py3-none-any.whl

Download URL xiaoaitts-0.1.1-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e68129d7c888a7c011cc3e2f351f85ecdbffd033c1cad3d2cc8fa242e3b07a7
BLAKE2b-256 checksum
How to use checksums
726d7c9dd03d2673ac529e3810ab839c05101bbb373ea4df724b04178c195cda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.10

Security for xiaoaitts 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page