Skip to content

vishalnagda1/text-to-speech

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Text To Speech

Text to speech is a Python program and can be used to read text. Currently it has English and Hindi language reading support via CLI arguments. For other language support you need to configure the code accordingly.

Requirements

System requirements:
  • You must have Python 3 installed in your system.
  • All commands should be run in Python 3 environment.
Prerequisite knowledge:
  • Basic understanding of Python
  • Basic understanding of Terminal or Command Prompt

Getting Started

  1. Create virtual environment
python3 -m venv .text-to-speech
  1. Activate the virtual environment
. .text-to-speech/bin/activate
  1. Install the required python packages
pip install -r requirements.txt
pip install pypiwin32 # Windows only
  1. Run the project
python main.py

Command Line Options

  1. -t or --text for cli input of text.
python main.py -t "This is input from command line"
  1. -l or --language for cli input of language. Currently it support Hindi and English. Available inputs are english and hindi.
python main.py -t Hello -l english
  1. -a or --accent for cli input of language accent. Only available for english language. Available accents are indian, australian, us and uk. For Hindi it is default set to indian accent.
python main.py -t Hello -l english -a uk
  1. -g or --gender for cli input of voice gender. Available inputs are male and female. By default it is set to male.
python main.py -t Hello -l english -a uk -g female
  1. -i or --index to select rank of the reader form the output list. It starts from 0 (Zero). If you don't select any index it will automatically take the first one.
python main.py -t Hello -l english -a us -g female -i 1

NOTE : Sometimes there might be chances that the readers are not available for specific gender or language or accent. In that case, it tries to find alternative or else it will read by the default reader which has English language, US accent and voice gender is male.

Troubleshooting

  • OSError: libespeak.so.1: cannot open shared object file: No such file or directory. Install libespeak library in your system. If you're using ubuntu you can do it by sudo apt install libespeak1.
# for Debian based OS
export LD_LIBRARY_PATH=/path/to/libespeak/directory:$LD_LIBRARY_PATH
  • aplay: not found your system needs alsa utils library. If you're on ubuntu you can do it by sudo apt-get install alsa-utils.

  • aplay: main:788: audio open error: No such file or directory or any other aplay related error. Your system should have soundcard on it. You can check this by aplay -l. As a result of this command if you see something like aplay: device_list:270: no soundcards found... this application will not work for you.

Dependencies

Contributing

  1. Fork it ( https://github.com/vishalnagda1/text-to-speech/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new pull request.