Wednesday 26 July 2017

When is it a good idea to not use NodeJs? Why?





When is it a good idea to not use NodeJs? Why? 
 
Because:
 
 
 
* If we want to create an application which is not much need OS  
server/user,Then we shouldn't use Nodejs. 
We would be just fine with other technology in very less time.




 
 * If we want to make an application which is required CPU Operations 
 frequently,Then we shouldn't use nodejs, Beacuse Nodejs bynature 
single threaded. When we launch a node process, you are running  
a single process with a single thread on a single core. So your 
 code will not be executed in parallel.
 So long running CPU tasks will block the whole server and are 
 usually a bad idea.
 
 



* If we are going to create a Simple blogs and static sites or Just 
 as a static file server then we shouldn't use Nodejs.


 
* No ability to scale out to take advantage of the multiple cores.






* Every time using a callback end up with tons of nested callbacks
 So using so many callbacks is not a good idea.









Tuesday 25 July 2017

Convert Speech to Text- Nodejs



Hi There ,
I am going to tell you how to convert Audio/Speech/Mp3 and other audio file into Text format.

I will use Nodejs, Bluemix (IBM Cloud Plateform).So let's start.

You should follow below steps to the same:

Step 1: Register on Bluemix (IBM Cloud Plateform).
Step 2: Login on Bluemix.
Step 3: Crete a service for speech-to-text. And get the username and password for speech-to-text.  Link : Create service for speech to text

Step 4:  Start coding.
Step 5:  create a .js file and require speech-to-text and fs just like below code.

 
var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
var fs = require('fs');



Step 6: Create an object of SpeechToText just like below code.



var speech_to_text = new SpeechToTextV1({
username: '1234567-8765-4267-9e76-fgff34f',
password: 'ABCdefghiJK'
});

Step 7: Create an array and insert the path of the audio. You can have many audio file in this array.

 
var files = ['./music/hello.flac','./music/somebody2010.flac'];



 Step 8: Create params for every audio, So we will do it in for loop and call speech_to_text.recognize() to convert.Get the response and console it.


for (var file in files) {
var params = {
audio: fs.createReadStream(files[file]),
content_type: 'audio/flac',
timestamps: true,
word_alternatives_threshold: 0.9,
keywords: ['colorado', 'tornado', 'tornadoes'],
keywords_threshold: 0.5
};

speech_to_text.recognize(params, function (error, transcript) {
if (error)
console.log('Error:', error);
else{
console.log(JSON.stringify(transcript, null, 2));
console.log(transcript.results[0].alternatives[0].transcript);
}
});
}

 Congratulation ! You did it.




The complete code is here :



 
 
var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
var fs = require('fs');

var speech_to_text = new SpeechToTextV1({
username: '1234567-8765-4267-9e76-fgff34f',
password: 'ABCdefghiJK'
});

var files = ['./music/hello.flac','./music/somebody2010.flac'];

for (var file in files) {
var params = {
audio: fs.createReadStream(files[file]),
content_type: 'audio/flac',
timestamps: true,
word_alternatives_threshold: 0.9,
keywords: ['colorado', 'tornado', 'tornadoes'],
keywords_threshold: 0.5
};

speech_to_text.recognize(params, function (error, transcript) {
if (error)
console.log('Error:', error);
else
console.log(transcript.results[0].alternatives[0].transcript);
});
}
 
 




HOW TO RUN ABOVE PROGRAM:

/***********************************************************************************
 INSTRUCTIONS:

Step 0: Check the environment setup. (Should installed nodejs,Remove all errors if any).
Step 1: Navigate terminal/command prompt to this directory.
Step 2: Run command:  node FILE_NAME.js;
Step 3: See the message  in console log;
Step 4: if executed Step 3 successfully then you have text message according to audio. Otherwise go to Step 0.

**************************************************************************************/





Wednesday 11 January 2017

Use of MYSQL Workbench



Hi friends,
Hope you all are enjoying your work.

Today i am going to show you how to use of mysql workbnch .


before doing this i am sure that you have already installed following things on your machine:

1. MYSQL.
2. MYSQL Workbench.



So now lets do this step by step.

Step 0.  Open your work bench by double clicking on your installed workbench icon.Its look like this :



Now you will have to click on + button nearby on your MYSQL Connections (+).
Then you will have to fill necessary things.


Step 1.  Now click on following place which is in red circle in below image to connect your local MYSQL database.







Step 2. After clicking on Local Instance 3306 you can see this like in below image:



Now you should enter your MYSQL password to connect your local database.


Step 3.  After entering password of MYSQL database , you will see this window :

In the above window , i had opened some sql file before, don't worry about that if the same is not opened on your machine.



Step 4. Now you will have to choose .sql file which you want to import in your database. So select the .sql file after clicking on below icon of this window.



Step 5.  After clicking on this icon you will have to choose file location where you are having your .sql file.

choose .sql file which you want to import on your database. ( Please double click on .sql file accordingly ). see in image :






Step 6. After selecting you desire .sql file you will see that , the window is opened with a tab having respective file name like that :




In the red area ( in  tab window ) you can see that there is many sql command written in that particular .sql file. Which is going to execute in next step.
Make sure that don't alter these sql commands.


Step 7. Now will have to execute these all sql commands which is in red area in above image.

To do this you will to click on this red area ( icon on the red area ) in below image . Click that particular icon in your workbench window:




Step 8. After clicking above icon your sql file will be executing. But it will take very little time to execute your all sql commands.


Ok fine, Your sql file has been executed. Now you can check the results and errors from following :
look just below on your main screen.



In the red area on above image all the sql log is recorded, you can open it by dragging up of action output area. The black arrow shows that it can be dragged up and down to show all errors or results.


Now you can execute all your .sql file one by one as described. You can execute many .sql file once, but doing one file one time is more better and safe.
So i suggest to do one by one.




Step 9. Check your database tables and Stored Procedures in your database. ( Do this after executing your all sql file ).

click on this icon which is in red area on below image:





Step 10:  If you are not able to see all database once then you can increase you view area by dragging this icon which is in red area on below image.







Check your tables in your particular database has been imported or not.
Be sure that all your Stored procedures has been imported or not.
You all database and tables is showing in red area. Also your stored procedures showing on red area in below images.:






If all your tables and stored procedures are showing then it successfully imported otherwise there may some error occurred when you imported or may be some wrong sql queries in .sql file.



 Please feel free to like , share links and comments for any query and support.


All The Best Friends..
Have a good time.