Wednesday, February 16, 2011

My childish try at Mimicry (.aka modelleing the Human voice box)



I am a huge fan of S.P. Balasubramaniam, been listening to his songs ever since i started hearing.  I mean who isn't. Always wished to sing like him, but never could as I was not gifted with it . But now things have changed so much over the years since my last thought that I can create any thing that I can virtually think of ( at least can attempt to do so) .Hence, the will to sing like S.P.B struck a chord  in my mind and out came an idea, an idea to mathematically model S.P.B's voice. I am very excited as this idea would allow me to sing through his voice. Not just me,but anyone who wanted to have a gifted voice can get a feeling of having one by singing words from one's mind through S.P.B voice.

Now, how am I going to make this happen ? That's where the excitement ends with the technical stuff silently creeping in. Here's the giant that's gonna make it all happen, the mighty "Digital Signal Processing".On a serious note which is not going to end so soon, the idea to replicate the structure of a human voice box (of one particular person) is a tedious task. The approach for now would be to examine the voice signal samples of a person from various perspectives ( domains ). The next step would involve finding a commonality between all the samples that makes his or her voice so unique.

MATLAB is the preferred platform to perform all of these studies as it provides the most flexibility ( slow though be the processing). The ultimate goal is to provide a mathematical model (a digital system ) capable of rendering in real time words from our mind through S.P.B's voice( our voice is fed through a mic to the PC).

FIRST STEP :

Working with audio input within the matlab environment is something that I am unaware of. Hence that would be the best area to start this project
Just as matlab allows importing image data into it's environment, it can also render real time analog data from various sources.But it requires the suitable hardware via which the analog signals from the outside can be brought in to the computer itself.Hence, if the computer has has the hardware , matlab takes care of the rest via the Data Acquisition Toolbox. Since I have already mentioned that the project demands real time signal processing , real time data  ,which is voice in our case , is going to be imported continuously into the matlab workspace via the PC's  audio input device (microphone).

>>ai=analoginput('winsound');     //this command creates an analog input object referred to via  variable 'ai'
                                                //winsound is the default driver to access the PC's sound input hardware (mic)

//the analog input is being imported into a digital environment in the form of samples at some sampling rate
// it depends on the driver hardware the sampling rate of the signal. All details are a part of object constructor //which in our case is 'ai'


>>ai;

Display Summary of Analog Input (AI) Object Using 'Integrated Microphone Array (ID'.

  Acquisition Parameters:  8000 samples per second on each channel.
                           20000 samples per trigger on each channel.
                           Inf sec. Of data to be logged upon START.
                           Log data to 'Memory' on trigger.

      Trigger Parameters:  Inf 'Immediate' trigger(s) on START.

           Engine status:  Waiting for START.
                           513515 samples acquired since starting.
                           453515 samples available for GETDATA.

AI object contains channel(s):

   Index:  channelname:  hwchannel:  inputrange:  sensorrange:  unitsrange:  Units:  
   1       'Mono'        1           [-1 1]       [-1 1]        [-1 1]       'Volts'

>> daqhelp('daq/audioinput');   //gives a list of all attributes of the analog input object that you can set.
                                               //you can explore a lot from there and know more about it

////out put too huge hence not shown. Most of the attributes are self commenting,not much explanation needed

//to set a property of the object 'set' command is used
//set(object_name,'PropertyName',PropertyValue)    //example say:

>> set(ai,'TriggerRepeat',Inf); //sets number of times the object may be triggered to infinity

//similarly ,there area whole bunch of properties one must set before working with the //object. These properties,though generally same, differ in some cases. Hence will be dealt //in detail when  working with one particular object.

One thing one must be clear with when working on some real time code is the process how the data is being acquired in real time. The following statements mostly concentrate on those areas.

//whenever a real time data is being manipulated, there is a lot of stress on the processor as data is //continuously being fed to it . Hence one must be careful not make a messy code with loops (matlab doesn't //understand loops as good as it understands arrays) . Try to use arrays wherever and whenever possible.


//whenever a real time data acquisition object is created and its properties aptly set to your need, it needs to be started.

//for example,consider you digital camera.. I suppose one needs to start it by clicking the ON button before //he can start clicking some snaps

>>start(obj1);                    //hence this command which starts the object for data/image acquisition.

//once the object's started ,it doesn't immediately start acquiring data/images.There is something similar to a CLICK button on a camera to begin acquiring data.


For an object, say an image acquisition object ( a webcam connected to PC ), if the trigger configuration is set to automatic, the object starts acquiring data /images the moment it starts. Instead if it is set to manual, object upon starting via the 'start' command does nothing until it is triggered. Each time a trigger occurs on the object, it logs data into the memory .The image below best illustrates the process.


>>trigger(ai);      //triggers data acquisition from the analog input object 'ai'

// the above figure illustrates a case of image acquisition, but audio data acquisition may also be understood //on similar lines

//once an object's been triggered, the data is logged to the memory and can be accessed via the getdata //command

>>dat=getdata(ai,20000);       //the second parameter defines the no of samples of the data to be imported //from memory to the workspace for further manipulation. 

//In this case the 20000 samples of data are extracted and saved into 20000 x 1 array 'dat'
// the data can now be accessed by the array itself.

>>>>>>>>>>>>>>>>>>>>>>that's it for now<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
COMINGUP:   Better understanding the analog input object and it's various attributes.
LIVEXample:   changing you voice in real time to sound like.


DO COMMENT IF THERE ARE ANY SHORT COMINGS IN THE EXPLANATION

                    I think.Hence I drive people nuts


1 comment:

  1. Great writing and thank you for sharing it with us I really like that … your idea is really appreciate able …
    Edmonton Mortgage

    ReplyDelete