Media
A Media Toolkit.
Text-to-speech is currently available.
Other features will be developed in the future.
Thanks for Microsoft Azure!
Release Note
-
0.1.4 - 0.1.6: Fixed some issues.
-
0.1.3:
- Added phonemes to improve pronunciation.
- Updated the documentation.
-
0.1.2:
- Added a link to the official site (Azure) to get the key.
- Fixed some issues.
-
0.1.1: Text-to-speech is currently available.
Quick Start
Get the keys
Text-to-speech
from media import Voice
text = "One Piece! Dragon Ball! Doraemon! Naruto!"
voice = Voice("YourSubscriptionKey", "YourServiceRegion")
# use English
voice.speak(text)
# use Japanese
voice.speak(text, lang=Voice.LANG.JA_JP, voice_name=Voice.NAME.FEMALE.JA_JP_NANAMI)
# Save the voice file to the local
voice.save(text)
Use phonemes to improve pronunciation
from media import Voice, SSML
voice = Voice("YourSubscriptionKey", "YourServiceRegion")
ssml = SSML()
# If you want to modify the phoneme of a word, add '[]' in text
ssml.voice = {
"text": "His name is Mike [Zhou]",
"phonemes": [{
"word": "Zhou",
"alphabet": "ups", # default: sapi
"ph": "JH AU",
}]
}
voice.speak(ssml)
The values of
alphabetandphcan refer to here, see: "Use phonemes to improve pronunciation - Azure"
Error detection
success = voice.speak()
if not success:
# do something...
print(voice.error)
# do something...
View the generated XML for SSML
from media import SSML
ssml = SSML()
# for human
print(ssml)
# for program
ssml.dump()
Full Example
Text-to-speech, in a different tone.
from media import Voice, SSML
voice = Voice("YourSubscriptionKey", "YourServiceRegion")
ssml = SSML(lang=SSML.LANG.ZH_CN, voice_name=SSML.NAME.FEMALE.ZH_CN_XIAO_XUAN)
ssml.voice = "啊?"
ssml.voice = {
"text": "这是可以说的吗?",
"role": SSML.ROLE.YOUNG_ADULT_FEMALE,
"style": SSML.STYLE.CHEERFUL,
"rate": SSML.RATE.MEDIUM,
}
ssml.voice = {
"text": "啊,可以可以",
"name": SSML.NAME.FEMALE.ZH_CN_XIAO_MO,
"style": SSML.STYLE.FEARFUL,
"role": SSML.ROLE.OLDER_ADULT_FEMALE,
"degree": "2",
}
ssml.voice = {
"text": "没事没事",
"name": SSML.NAME.FEMALE.ZH_CN_XIAO_MO,
"style": SSML.STYLE.SAD,
"role": SSML.ROLE.OLDER_ADULT_FEMALE,
"degree": "2",
"rate": SSML.RATE.FAST,
}
# It will play the generated speech
voice.speak(ssml)
If you want to save:
voice.save(ssml)
If you want to save and customize the name or location:
voice.save(ssml, path="这是可以说的吗.mp3")
Metadata
Release files for media 0.1.6
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 | Actions |
|---|---|---|---|---|
| media-0.1.6.tar.gz | 8.5 kB | Without provenance | Details for media-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| media-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for media-0.1.6-py3-none-any.whl |
Total release size: 16.8 kB
Release files / media-0.1.6.tar.gz
| Download URL | media-0.1.6.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92453789ade4943c74819ea2ec617f00e71164708884a7129096dc0ec691c061
|
|
BLAKE2b-256 checksum How to use checksums |
ede783d0ea412daa132c69a1a1d2a27a155f7e6cb850c651c5a2f47850e2018f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.0.2rc1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.6
|
Release files / media-0.1.6-py3-none-any.whl
| Download URL | media-0.1.6-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
934321a39c2d8d4d0a89a11af4a0b1a7cc67b41e9d65a0546ef248ba25fd110e
|
|
BLAKE2b-256 checksum How to use checksums |
e509c05b1f9fc33f243fd190afc54a8ca210b545e5b79c14a966a06e95d8be32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.0.2rc1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.6
|
Security for media 0.1.6
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.