概述
基于讯飞TTS语音合成API的文字转语音功能,将文字信息转化为声音信息,给掌控板配上“嘴巴”。其合成音在音色、自然度等方面的表现均接近甚至超过了人声。目前应用于掌控拓展板。
- 更多的mPython library:https://github.com/labplus-cn/mPython-lib
- mPython library Documentation: https://mpython-lib.readthedocs.io
库的安装方法
可通过以下任一方法进行安装。
- 将项目中的
tts.py和依赖于base64.py拷到掌控板文件系统上 - 在掌控板REPL界面中,使用upip安装,步骤如下:
- 前置条件需要掌控板连接网络
- 导入upip模块,执行
import upip - 执行`upip.install('mPython-tts')
>>> import upip
>>> upip.install('mPython-tts')
使用
该功能使用讯飞的在线语音合成服务,需要用户自行在在讯飞开发平台 https://www.xfyun.cn/ 注册账号,步骤如下:
- 注册账号
- 新建产品,选择“在线语音合成”服务。
- 在IP白名单中添加网络的公网IP。
示例:
from mpython import *
from tts import *
mywifi=wifi()
mywifi.connectWiFi('ssid','password') #连接 WiFi 网络
APPID = "" # 讯飞应用ID
API_KEY = "" # 讯飞应用的api key
tts=TTS(APPID,API_KEY) #构建TTS实例,并传入appid,api key 参数.
# 沁园春·长沙 诗词
poem= "独立寒秋,湘江北去,橘子洲头。 \
看万山红遍,层林尽染;漫江碧透,百舸争流。\
鹰击长空,鱼翔浅底,万类霜天竞自由。\
怅寥廓,问苍茫大地,谁主沉浮?\
携来百侣曾游。忆往昔峥嵘岁月稠。\
恰同学少年,风华正茂;书生意气,挥斥方遒。\
指点江山,激扬文字,粪土当年万户侯。\
曾记否,到中流击水,浪遏飞舟?"\
tts.translate(poem) # 文字转语音并播放
执照
所有代码均在MIT许可下发布。
Metadata
Release files for mPython-tts 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mPython-tts-0.1.0.tar.gz | 3.4 kB | Without provenance | Details |
Release files / mPython-tts-0.1.0.tar.gz
| Download URL | mPython-tts-0.1.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a7a721c2166d7204e4a547f3a9ec9637155cdc03d1952a9d77cfbe4159bad81
|
|
BLAKE2b-256 checksum How to use checksums |
67796b0cbcfd943157680a8d75a031264e93f905510e74599e279a3b332a3725
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for mPython-tts 0.1.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.