macos_speech
Ever wanted to leverage the macOS builtin speech synthesis directly into python ? Or just make your code to talk...
With the Python macos_speech package you can do it in a pythonic way. Easy and zen.
Getting Started:
Installation
pip install macos_speech
or
git clone https://github.com/tibOin/macos_speech.git
cd macos_speech
pip install .
Requirements
macOS 10.x or for oldest OS X
For now, this package only works on Python >= 2.6 and Python >= 3.6.x
Only tested on Python 2.7.10 and >= 3.7.2.
Basic usage
from macos_speech import Synthesizer
speaker = Synthesizer(voice='Alex', device='Built-in')
speaker.text = """How my God! I can make my python code to talk!
And I can even send multiple lines! Awesome.
"""
speaker.talk()
# or
speaker.say("Hello!")
Get informations
from macos_speech import Synthesizer
speaker = Synthesizer()
print('''Voices:
NAME LANGUAGE DESCRIPTION
''')
for voice in speaker.voices:
print('{} {} {}'.format(voice.name, voice.lang, voice.desc))
print('')
print('Audio devices:')
for device in speaker.devices:
print('ID: {}, NAME: {}'.format(device.id, device.name))
print('')
print('''Output file possible formats:
ID NAME FILE_EXT DATA_FORMATS BIT_RATES
''')
for format in speaker.formats:
print('{} {} ({}) [{}] [{}]'.format(format.id, format.name,
','.join(format.exts),
','.join(format.formats),
','.join(format.bitrates)))
Synthesizer Properties
from macos_speech import Synthesizer
synthe = Synthesizer()
# Helper properties
synthe.devices
synthe.voices
synthe.formats
# Configuration properties
# File IO (takes absolute pathes strings)
synthe.infile # A file containing text to say (mutually exclusive with self.text - high priority)
synthe.outfile # The output audio file (default should be 'output.aiff'
# but you can specify file and data formats)
# Simple configs (takes strings)
synthe.rate # The speech rate
synthe.quality # The audio quality (between 0 and 127 both included)
synthe.text # The text to say (mutually exclusive with self.infile - low priority)
# Pythonified configs (takes macos_speech.CustomClasses)
synthe.format # The audio output file/data format : macos_speech.AudioFormat
# (Works only with self.outfile populated)
synthe.device # The audio output device : macos_speech.AudioDevice
# (or 'name' or 'id' on Python 3)
# (Only used if no self.outfile)
synthe.voice # The voice to use : macos_speech.Voice
# (or 'name' on Python 3)
Go Further
from macos_speech import Synthesiser, AudioFormat
# Speech manipulation:
# To create more realistic speech you can play on time and rate.
# You can add delays between words by following a simple syntax.
# Just set the delay by writing time in milliseconds between brackets.
mytext = 'I want to say... [100] something.'
# And/Or specify a rate in words per minutes to your Synthesiser
synthe = Synthesiser(voice='Alex', rate=50, text=mytext)
# Record to file:
# Basically, setting an outfile with supported extension would be enough to correctly encode the file.
speaker = Synthesiser(voice='Alex', text='Some text to record', outfile='rec.mp4')
# But you can customize a lot more your output file:
format = AudioFormat('3gp2', dataformat='Qclp', bitrate=13000)
speaker = Synthesiser(voice='Alex', text= "Some text", format=format, outfile='out.3g2')
Metadata
Release files for macos-speech 1.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 | Actions |
|---|---|---|---|---|
| macos_speech-1.1.0.tar.gz | 5.1 kB | Without provenance | Details for macos_speech-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| macos_speech-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for macos_speech-1.1.0-py3-none-any.whl |
Total release size: 11.0 kB
Release files / macos_speech-1.1.0.tar.gz
| Download URL | macos_speech-1.1.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65344b3acc2e310725fb4de5c3e2526edb7cc270929c780566d9123ab2407120
|
|
BLAKE2b-256 checksum How to use checksums |
f27a80e11e649bf1b5b0365978952229f46f9ce5b9e7c080c8fda1cb12291a12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.1
|
Release files / macos_speech-1.1.0-py3-none-any.whl
| Download URL | macos_speech-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e17742edeae687a9de849f101813d04597333bd4604d0044447ed698fc45b3b
|
|
BLAKE2b-256 checksum How to use checksums |
59409969e683bef606c522c11ef19a24d54e12ebf77798b4c2f804bae7871348
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.1
|
Security for macos-speech 1.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.