Friday, February 14, 2014
Read wave files in Python
Now a days python developers developed many scientific tools which can be useful in your research. If you started research in Speech signal process then it is necessary to know 'how to read a wavefile in computer'. If you know the MATLAB then it is pretty straight forward to read or write wavefiles, direct command like "wavread" or "wavwrite". But if you want to do the same operations in Python it is not straight forward. However, in Python numerous packages are provided for reading a wavefile like "scipy.io.wavfile.read" or "scikits.audiolab", etc. If you read the wavefiles using the "scipy" package it returns the integer values not the float values like in MATLAB. Here I provided the small snippet to read the wavefile like in MATLAB.
%in matlab to read wavefiles
s, fs = wavread('file')
% values in s are float values and fs represents the sampling frequency
from scipy.io import wavfile as wav
fs, x = wav.read('file') #fs is sampling frequency and x is integer numpy array
# If you know the samplewidth (most of the cases it is 2 bytes (16bits))
# the integer values lies between -2^15 to 2^15
# to convert the integers to float values like in MATLAB
# just divide the integers array by 2^15 = 32768
x = x/32768.0 # don't forget to convert the 32768 to 32768.0
# Now values in x are same as values in s
Scipy package doesn't support the 24-bit samplewidth files. For more information, please go through this link Waveio which provided the solution to read the wavefile without scipy package.
Monday, February 3, 2014
Small tricks to remember
Most of the times the output of SPTK or HTS are in binary file format. To read the binary files in Python using NumPy. Use the following command:
## commands for reading the binary file in python
import numpy as np
#to read a binary file
a = np.fromfile("file.name",dtype='<f4',count=-1)
Here dtype means datatype in general the size of datatype will be 32bit. Suppose if it is 16bit size then change the '<f4' to '<f2'.
Suppose if you want to write an ASCII file into a binary file then use the following command:
#to write into a binary file
np.ndarray.tofile(a,"file.name")
Where "a" can be a list or matrix with float numbers.
Speech synthesis from Coursera Lectures - 1
These days we are finding alot of speech data for free on Internet. Take an example: Coursera lectures where each professor teach lessons to students for free in online by recording his lectures. These records contain both audio and video streams. The good thing is that they all provided with the subtitles (transcript). Most of the lectures you find on Coursera are in English. With the advances in Speech technology especial in Speech synthesis, we can synthesis voices from the lecture videos. But there are some challenges involved in this procedure. I will list some of the problems here:
1) Recording conditions. Actually this is a tough problem because we don't know how far the microphone is located. What type of noises are mixed in the recordings (ex: Fan or A/C sound, cough, writing sound..etc). In this case we have to apply speech enhancement techniques to remove any background noises.
2) Audio extraction. We know that band-width and memory space available on Internet are limited. So most of the times videos are post-processed to compress the size. In general, they don't specify the compression techniques used for the compression. If they used the lossy compression like MPEG then we can't restore the original quality otherwise we can restore the original quality by inverse process.
3) Text alignment with audio. We commonly see that subtitles are either delayed or rushed by few seconds. In human perception we don't bother about these small mismatches. But in speech technology they play a major role. So, in this we have to apply some text alignment tools to correct this mismatches.
4) Length of utterances. Traditional speech synthesis systems use the read aloud sentences which usually have length of 6-7 words, for training. But in lectures we will find a variety of length utterances because in most of the situations professors explains things from his experience not by reading some pre-written text.
With these four main issues there will be some minor issues which I will discuss in coming posts.
Labels:
Course era voice plug-in,
Coursera,
Speech synthesis
Saturday, March 6, 2010
An interesting observation about NINE (9)..
9+1 = 10 = 1+0 = 1; 9*1 = 9;
9+2 = 11 = 1+1 = 2; 9*2 = 18 = 1+8 = 9;
9+3 = 12 = 1+2 = 3; 9*3 = 27 = 2+7 = 9;
9+4 = 13 = 1+3 = 4; 9*4= 36 = 3+6 =9;
9+5 = 14 = 1+4= 5; 9*5= 45 = 4+5=9;
9+6 = 15 = 1+5 = 6; 9*6= 54 = 5+4=9;
9+7 = 16 = 1+6 = 7; 9*7 = 63 = 6+3= 9;
9+8 = 17 = 1+7 = 8; 9*8 = 72 = 7+2 = 9;
9+9 = 18 = 1+8 = 9; 9*9 = 81 = 8+1 =9;
This what I was observed when I am adding phone number to a single number. suppose number 1234 = 1+2+3+4=10=1+0=1, if u add 9 to this number 1234+9 = 1243 =1+2+4+3=10=1+0=1 it is same as before number sum. It is applicable to any number. Can anyone tell the reason why it is happening ?? ( I know the reason.. :P)
9+2 = 11 = 1+1 = 2; 9*2 = 18 = 1+8 = 9;
9+3 = 12 = 1+2 = 3; 9*3 = 27 = 2+7 = 9;
9+4 = 13 = 1+3 = 4; 9*4= 36 = 3+6 =9;
9+5 = 14 = 1+4= 5; 9*5= 45 = 4+5=9;
9+6 = 15 = 1+5 = 6; 9*6= 54 = 5+4=9;
9+7 = 16 = 1+6 = 7; 9*7 = 63 = 6+3= 9;
9+8 = 17 = 1+7 = 8; 9*8 = 72 = 7+2 = 9;
9+9 = 18 = 1+8 = 9; 9*9 = 81 = 8+1 =9;
This what I was observed when I am adding phone number to a single number. suppose number 1234 = 1+2+3+4=10=1+0=1, if u add 9 to this number 1234+9 = 1243 =1+2+4+3=10=1+0=1 it is same as before number sum. It is applicable to any number. Can anyone tell the reason why it is happening ?? ( I know the reason.. :P)
Wednesday, January 20, 2010
U.. that's all
How I feel, if I am not seeing u..? It is like a blind man searching in light..
How I feel, if I am not thinking about u..? It is like a madman thinking about himself..
How I feel, if I am not talking to u..? It is like a dumb..
You may think of me or not, but I am always thinking about u..
You may speak to me or not, but I want talk to u..
You may see me or not, but I am always seeing u..
You may like me or not, but I am liking u..
To wake at dawn with winged heart and give thanks for another day of loving..
To rest at noon hour and meditate love's ecstasy
To sleep with a prayer for the beloved in ur heart and a song of praise upon ur lips
How I feel, if I am not thinking about u..? It is like a madman thinking about himself..
How I feel, if I am not talking to u..? It is like a dumb..
You may think of me or not, but I am always thinking about u..
You may speak to me or not, but I want talk to u..
You may see me or not, but I am always seeing u..
You may like me or not, but I am liking u..
To wake at dawn with winged heart and give thanks for another day of loving..
To rest at noon hour and meditate love's ecstasy
To sleep with a prayer for the beloved in ur heart and a song of praise upon ur lips
Friday, January 8, 2010
Memories-1
Hmmm.. every one remembers their school life memories.., I am also remembered the one which I never forget untill now. I spent all my school days in a hostel and the school name is Jawahor Navodaya Vidhyalayam Maddirala (JNVM.. the place which changed me completely :D). This is how I ragged a junior and how I caught to principal .....
Now a days everyone facing ragging in their college days but for me I already faced in my school life. Seniors were ragged only 6th to 9th class students, so they were ragged me also. I decided to rag juniors in my 10th class.
One fine Sunday just before our preboard exams, our maths teacher sumathi madam asked us to do problems. So some of us decided to sit another place instead of classroom and we asked the madam, she gave us permission to sit another place ( Madam had the impression that I am good at maths). As we were students, feeling boredom to solve that problems so we want some entertainment and googling what to do. Juniors were wondering on the roads, they looked like entertainers. I called the one junior.
Junior name was Raviteja, he just looked like perfect entertainer with his belly stomach . My frnd Jilani and I were decided to do some fun with him, tie a shoe on his backside like a tail. So Jilani was talking with him in the meantime I tied the shoe without noticing to him . We ordered him just leave this place, we laughed fully when he was leaving our place with a tail. Actually I didn't noticed that he was weeping at that time.
That was how I ragged a junior. But afterwards things had changed, he complained to his father about that incident . I will write in next post what happened to us... :(
Now a days everyone facing ragging in their college days but for me I already faced in my school life. Seniors were ragged only 6th to 9th class students, so they were ragged me also. I decided to rag juniors in my 10th class.
One fine Sunday just before our preboard exams, our maths teacher sumathi madam asked us to do problems. So some of us decided to sit another place instead of classroom and we asked the madam, she gave us permission to sit another place ( Madam had the impression that I am good at maths). As we were students, feeling boredom to solve that problems so we want some entertainment and googling what to do. Juniors were wondering on the roads, they looked like entertainers. I called the one junior.
Junior name was Raviteja, he just looked like perfect entertainer with his belly stomach . My frnd Jilani and I were decided to do some fun with him, tie a shoe on his backside like a tail. So Jilani was talking with him in the meantime I tied the shoe without noticing to him . We ordered him just leave this place, we laughed fully when he was leaving our place with a tail. Actually I didn't noticed that he was weeping at that time.
That was how I ragged a junior. But afterwards things had changed, he complained to his father about that incident . I will write in next post what happened to us... :(
Sunday, July 5, 2009
'You've got to find what you love,' Jobs says-II
This is the text of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005. It was a wonderful & inspirational speech. He talked about 15 minutes about three stories in his life. Speech follows like this....
My second story is about love and loss.
I was lucky — I found what I loved to do early in life. Woz and I started Apple in my parents garage when I was 20. We worked hard, and in 10 years Apple had grown from just the two of us in a garage into a $2 billion company with over 4000 employees. We had just released our finest creation — the Macintosh — a year earlier, and I had just turned 30. And then I got fired. How can you get fired from a company you started? Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out. When we did, our Board of Directors sided with him. So at 30 I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating
I really didn't know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down - that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to dawn on me — I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And so I decided to start over.
I didn't see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.
During the next five years, I started a company named NeXT, another company named Pixar, and fell in love with an amazing woman who would become my wife. Pixar went on to create the worlds first computer animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, I returned to Apple, and the technology we developed at NeXT is at the heart of Apple's current renaissance. And Laurene and I have a wonderful family together.
I'm pretty sure none of this would have happened if I hadn't been fired from Apple. It was awful tasting medicine, but I guess the patient needed it. Sometimes life hits you in the head with a brick. Don't lose faith.I'm convinced that the only thing that kept me going was that I loved what I did. You've got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.
second story ends..
My second story is about love and loss.
I was lucky — I found what I loved to do early in life. Woz and I started Apple in my parents garage when I was 20. We worked hard, and in 10 years Apple had grown from just the two of us in a garage into a $2 billion company with over 4000 employees. We had just released our finest creation — the Macintosh — a year earlier, and I had just turned 30. And then I got fired. How can you get fired from a company you started? Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out. When we did, our Board of Directors sided with him. So at 30 I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating
I really didn't know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down - that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to dawn on me — I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And so I decided to start over.
I didn't see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.
During the next five years, I started a company named NeXT, another company named Pixar, and fell in love with an amazing woman who would become my wife. Pixar went on to create the worlds first computer animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, I returned to Apple, and the technology we developed at NeXT is at the heart of Apple's current renaissance. And Laurene and I have a wonderful family together.
I'm pretty sure none of this would have happened if I hadn't been fired from Apple. It was awful tasting medicine, but I guess the patient needed it. Sometimes life hits you in the head with a brick. Don't lose faith.I'm convinced that the only thing that kept me going was that I loved what I did. You've got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.
second story ends..
Saturday, July 4, 2009
'You've got to find what you love,' Jobs says - I
This is the text of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005. It was a wonderful & inspirational speech. He talked about 15 minutes about three stories in his life. Speech follows like this....
I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I've ever gotten to a college graduation. Today I want to tell you three stories from my life. That's it. No big deal. Just three stories.
The first story is about connecting the dots.
I dropped out of Reed College after the first 6 months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?
It started before I was born. My biological mother was a young, unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: "We have an unexpected baby boy; do you want him?" They said: "Of course." My biological mother later found out that my mother had never graduated from college and that my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would someday go to college.
And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents' savings were being spent on my college tuition. After six months, I couldn't see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending all of the money my parents had saved their entire life. So I decided to drop out and trust that it would all work out OK. It was pretty scary at the time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop taking the required classes that didn't interest me, and begin dropping in on the ones that looked interesting.
It wasn't all romantic. I didn't have a dorm room, so I slept on the floor in friends' rooms, I returned coke bottles for the 5¢ deposits to buy food with, and I would walk the 7 miles across town every Sunday night to get one good meal a week at the Hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example:
Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn't have to take the normal classes, I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can't capture, and I found it fascinating.
None of this had even a hope of any practical application in my life. But ten years later, when we were designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the Mac would have never had multiple typefaces or proportionally spaced fonts. And since Windows just copied the Mac, its likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on this calligraphy class, and personal computers might not have the wonderful typography that they do.Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards ten years later.
I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I've ever gotten to a college graduation. Today I want to tell you three stories from my life. That's it. No big deal. Just three stories.
The first story is about connecting the dots.
I dropped out of Reed College after the first 6 months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?
It started before I was born. My biological mother was a young, unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: "We have an unexpected baby boy; do you want him?" They said: "Of course." My biological mother later found out that my mother had never graduated from college and that my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would someday go to college.
And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents' savings were being spent on my college tuition. After six months, I couldn't see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending all of the money my parents had saved their entire life. So I decided to drop out and trust that it would all work out OK. It was pretty scary at the time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop taking the required classes that didn't interest me, and begin dropping in on the ones that looked interesting.
It wasn't all romantic. I didn't have a dorm room, so I slept on the floor in friends' rooms, I returned coke bottles for the 5¢ deposits to buy food with, and I would walk the 7 miles across town every Sunday night to get one good meal a week at the Hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example:
Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn't have to take the normal classes, I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can't capture, and I found it fascinating.
None of this had even a hope of any practical application in my life. But ten years later, when we were designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the Mac would have never had multiple typefaces or proportionally spaced fonts. And since Windows just copied the Mac, its likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on this calligraphy class, and personal computers might not have the wonderful typography that they do.Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards ten years later.
Again, you can't connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something — your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.first story ends..
Subscribe to:
Posts (Atom)
