Download English Dictionary words for Microcontroller based Text to Speech (TTS) convertor:





What is TTS?
Speech synthesis is the artificial production of human speech. A computer system used for this purpose is called a speech computer or speech synthesizer, and can be implemented in software or hardware products. A text-to-speech (TTS) system converts normal language text into speech; other systems render symbolic linguistic representations like phonetic transcriptions into speech.
Basic architecture is explained in following block diagram.
 
Microcontroller feed with text data from any interface . microcontroller make tokens of that string into and compare appropriate soud file per word from data bases. After getting all index of each word of string micro controller play sound files one after another with proper delay in words.

As per post title I am going to use Python script to make my own speech files database(format in mp3).


Prerequisite :
1) Installed python 2.7 ( Download and install from https://www.python.org/download/releases/2.7/)
2) Internet

Step 1:
locate Python27\Scripts director

install requred python packages

press and hold shift key and rigth click > click open command window here

in command prompt type and enter

pip.exe install wget


this is package used by our script to download .mp3 files from internet

Step 2:

We are going to download all our .mp3 file from google database.
we need to replace “hello.mp3” with our word that we want to download.

Step 3:

Here I used the file words.txt that contains daily used English words. We take each word from file and replace in base URL to download it.




download this this file and keep it in same directory where following script is placed.

Step 4:

create new text file, copy and paste following code in it. Rename that file as script.py

import wget
import os
import os.path

with open("words.txt", "r") as ins:

def chomp(x):
if x.endswith("\r\n"): return x[:-2]
if x.endswith("\n"): return x[:-1]
return x[:]

for line in ins:
line=chomp(line)+".mp3"
if False==os.path.isfile(line):
print "new file added\n"
file_url = "https://ssl.gstatic.com/dictionary/static/sounds/de/0/"
file_url=file_url+line
print file_url
file_name = wget.download(file_url)
else :
print "file exist"

Step5:
open command prompt from director of script and run script as

> python script.py

Step 6:

Download will take time as their is load of words in text file. you can reduce them as per your requirement.

Now you have you mp3 database for text to speech converter. I have working prototype for it using microcontroller.
If you have any question please comment below or contact me.

Comments

Popular posts from this blog