Skip to main content

小爱音箱自定义文本朗读

Project description

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')

参考链接

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xiaoaitts-0.1.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xiaoaitts-0.1.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file xiaoaitts-0.1.1.tar.gz.

File metadata

  • Download URL: xiaoaitts-0.1.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.10

File hashes

Hashes for xiaoaitts-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6f07955eb08f4b33bf34413907d61bea1fc0f2b2c1348ba74af01f7ecb02941e
MD5 3d501dbd6df039230323ee956c622517
BLAKE2b-256 049bb3e5eab3b0cab971839cf701654e17eddbfb0ec9b7e5634c21583abc143e

See more details on using hashes here.

File details

Details for the file xiaoaitts-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: xiaoaitts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.10

File hashes

Hashes for xiaoaitts-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e68129d7c888a7c011cc3e2f351f85ecdbffd033c1cad3d2cc8fa242e3b07a7
MD5 00ea6ef65f3816b678ae526b7e50559b
BLAKE2b-256 726d7c9dd03d2673ac529e3810ab839c05101bbb373ea4df724b04178c195cda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page