Giter VIP home page Giter VIP logo

xiaoaitts's Introduction

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

参考链接

xiaoaitts's People

Contributors

cnmax avatar

Stargazers

 avatar farwmarth avatar EnemyDirector avatar  avatar jangkyuenbin avatar  avatar unliu avatar  avatar yjun avatar  avatar  avatar 紫菜苔 avatar MikuSugar avatar yihong avatar  avatar Too large to fit in the margin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.