NLTK requires Python versions 3.5, 3.6, 3.7, or 3.8
- Gtts Python Install
- Download Gtts Python
- Install Gtts For Python In Mac Download
- Python Gtts Languages List
For Windows users, it is strongly recommended that you go through this guide to install Python 3 successfully https://docs.python-guide.org/starting/install3/win/#install3-windows
Hi @macelux.Indeed looks like a bug! Will fix and add tests, mostly likely this weekend. Thanks for asking on SO too, great response over there! The official home of the Python Programming Language. While Javascript is not essential for this website, your interaction with the content will be limited. The installation program displays late-breaking notes about Python, licensing information (click Agree when asked about the licensing information), and, finally, a destination dialog box. Select the Volume (hard drive or other media) that you want to use for installing Python and click Continue. The Installation Type dialog box appears. The Mac operating system ships with the version of Python already installed. If you're using Windows, please skip to the next video, as I'll walk you through how to get set up. GTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate's text-to-speech API. Write spoken mp3 data to a file, a file-like object (bytestring) for further audio manipulation,.
Setting up a Python Environment (Mac/Unix/Windows)¶
Please go through this guide to learn how to manage your virtual environment managers before you install NLTK, https://docs.python-guide.org/dev/virtualenvs/
Alternatively, you can use the Anaconda distribution installer that comes “batteries included” https://www.anaconda.com/distribution/
Mac/Unix¶
Install NLTK: run
pipinstall--user-Unltk
Install Numpy (optional): run
pipinstall--user-Unumpy
Test installation: run
python
then typeimportnltk
For older versions of Python it might be necessary to install setuptools (see http://pypi.python.org/pypi/setuptools) and to install pip (sudoeasy_installpip
).
Windows¶
These instructions assume that you do not already have Python installed on your machine.
32-bit binary installation¶
Install Python 3.8: http://www.python.org/downloads/ (avoid the 64-bit versions)
Install Numpy (optional): https://www.scipy.org/scipylib/download.html
Install NLTK: http://pypi.python.org/pypi/nltk
Test installation:
Start>Python38
, then typeimportnltk
Installing Third-Party Software¶
Please see: https://github.com/nltk/nltk/wiki/Installing-Third-Party-Software
Installing NLTK Data¶
After installing the NLTK package, please do install the necessary datasets/models for specific functions to work.
If you’re unsure of which datasets/models you’ll need, you can install the “popular” subset of NLTK data, on the command line type python -m nltk.downloader popular, or in the Python interpreter import nltk; nltk.download(‘popular’)
For details, see http://www.nltk.org/data.html
Gtts Python Install
Text-to-Speech (TTS) is a kind of speech synthesis which converts typed text into audible human-like voice.
There are several speech synthesizers that can be used with Python. In this tutorial, we take a look at three of them: pyttsx
, Google Text-to-Speech
(gTTS) and Amazon Polly
.
We first install pip
, the package installer for Python.
If you have already installed it, upgrade it.
We will start with the tutorial on pyttsx
, a Text-to-Speech (TTS) conversion library compatible with both Python 2 and 3. The best thing about pyttsx
is that it works offline without any kind of delay. Install it via pip
.
By default, the pyttsx3 library loads the best driver available in an operating system: nsss
on Mac, sapi5
on Windows and espeak
on Linux and any other platform.
Import the installed pyttsx3
into your program.
Here is the basic program which shows how to use it.
Now let us change the voice in pyttsx3
from male to female. If you wish for a female voice, pick voices[10]
, voices[17]
from the voices
property of the engine. Of course, I have picked the accents which are easier for me to make out.
You can actually loop through all the available voices and pick the index of the voice you desire.
Now, Google also has developed an application to read text on screen for its Android operating system. It was first released on November 6, 2013.
It has a library and CLI tool in Python called gTTS to interface with the Google Translate text-to-speech API.
We first install gTTS via pip
.
gTTS creates an mp3 file from spoken text via the Google Text-to-Speech API.
We will install mpg321 to play these created mp3 files from the command-line.
Using the gtts-cli
, we read the text 'Hello, World!'
and output it as an mp3 file.
We now start the Python interactive shell known as the Python Shell
You will see the prompt consisting of three greater-than signs (>>>
), which is known as the Python REPL prompt.
Import the os
module and play the created hello.mp3
file.
Putting it all together in a single .py
file
The created hello.mp3
file is saved in the very location where your Python program is.
gTTS supports quite a number of languages. You will find the list here.
The below line creates an mp3 file which reads the text '你好' in Chinese.
The below program creates an mp3 file out of text '안녕하세요' in Korean and plays it.
Amazon also has a cloud-based text-to-speech service called Amazon Polly.
If you have an AWS account, you can access and try out the Amazon Polly console here:
The interface looks as follows.
There is a Language and Region
dropdown to choose the desired language from and several male and female voices to pick too. Pressing the Listen to speech
button reads out the text typed into the text box. Also, the speech is available to download in several formats like MP3, OGG, PCM and Speech Marks.
Now to use Polly in a Python program, we need an SDK. The AWS SDK for Python is known as Boto.
Download Gtts Python
We first install it.
Now to initiate a boto session, we are going to need two more additional ingredients: Access Key ID and the Secret Access Key.
Login to your AWS account and expand the dropdown menu next to your user name, located on the top right of the page. Next select My Security Credentials
from the menu.
A pop-up appears. Click on the Continue to Security Credentials
button on the left.
Install Gtts For Python In Mac Download
Expand the Access keys
tab and click on the Create New Access Key
button.
Python Gtts Languages List
As soon as you click on the Create New Access Key
button, it auto creates the two access keys: Access Key ID, a 20-digit hex number, and Secret Access Key, another 40-digit hex number.
Now we have the two keys, here is the basic Python code which reads a given block of text, convert it into mp3 and play it with mpg321
.
There is also another way to configure Access Key ID and the Secret Access Key. You can install awscli
, the universal command-line environment for AWS,
and configure them by typing the following command.
Notes
- The latest documentation on
pyttsx3
is available here. - You can also access the updated documentation on gTTS here.