Dhananjay Khairnar @. Powered by Blogger.

29 November 2016

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:
if False==os.path.isfile(line):
print "new file added\n"
file_url = "https://ssl.gstatic.com/dictionary/static/sounds/de/0/"
print file_url
file_name = wget.download(file_url)
else :
print "file exist"

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.
Published: By: DK - 04:03

10 November 2016

Raspberry pi 3 kernel module compilation:


Raspberry pi 3 kernel module compile :

Step 1:
Update current kernel

$sudo apt-get update

$sudo apt-get upgrade

$sudo apt-get install bc

$sudo apt-get install gcc

Step 2:
Download linux headers for current kernel version

$uname -r

copy kernel version

and goto url https://www.niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi/ and find your kernel version
here in my case
linux-headers-4.4.26-v7+_4.4.26-v7+-2_armhf.deb    20-Oct-2016 21:07             6891064

Download it

Now install the downloaded inux headers.

$sudo dpkg -i linux-headers-4.4.26-v7+_4.4.26-v7+-2_armhf.deb

it takes while let it be complete without interrupt process.

Step 4 :

$mkdir kmod

$cd kmod

$sudo nano hello-1.c

copy and past following programe in file then save it [^X]

/*hello−1.c − The simplest kernel module.*/
#include < linux/init.h >             //linux/init.h Macros used to mark up functions e.g., __init __exit
#include < linux/module.h >           //linux/module.h Core header for loading LKMs into the kernel
#include < linux/kernel.h >           //linux/kernel.h Contains types, macros, functions for the kernel

int init_module(void) 
    printk(KERN_INFO "Hello world 1.\n");
    /*A non 0 return means init_module failed; module can't be loaded.*/
    return 0;

void cleanup_module(void)
    printk(KERN_INFO "Goodbye world 1.\n");

Now for compile this module we need make file
$sudo nano Makefile

copy and past following code in make file

obj-m += hello-1.o

    make -C /lib/modules/4.4.26-v7+/build M=/home/pi/kmod modules
    make -C /lib/modules/4.4.26-v7+/build M=/home/pi/kmod clean

remember the there is Tab before make.

Save it

Step 5:

compile our hello world module

$sudo make
make -C /lib/modules/4.4.26-v7+/build M=/home/pi/kmod modules

make[1]: Entering directory '/usr/src/linux-headers-4.4.26-v7+'

CC [M] /home/pi/kmod/hello-1.o

Building modules, stage 2.

MODPOST 1 modules

CC /home/pi/kmod/hello-1.mod.o

LD [M] /home/pi/kmod/hello-1.ko

make[1]: Leaving directory '/usr/src/linux-headers-4.4.26-v7+'

Step 6:
insert module into kernel
$sudo insmod hello-1.ko

if there is noerror then your module get successfully installed

Step 7:
to verify it
$sudo dmesg

You get following result 

now to remove module 

$sudo rmmod hello-1.ko

to verify

$sudo dmesg

you see the kernel log as follows


Thank You . if you have any question comment below or email me.

Published: By: DK - 07:49