简体   繁体   中英

Node JS express and console output to command line versus browser

I am new to node js and am working with IBM's speech to text sample application ( https://github.com/watson-developer-cloud/speech-to-text-nodejs ). It uses the express framework and prints transcribed audio from the microphone to a text box on the webpage as well as the browser console. Other examples I have seen using express have outputed to the command line console. Can anyone explain to me why console.log is outputing to the browser console instead of the command line?

Thanks so much

console.log outputs into browser console because it runs on client-side. In few sentences: When you type ' http://localhost:3000 ' in your browser, your browser makes GET request to '/' of your nodejs app. As you can see, this request is processed at 47 line of app.js. Your application renders ./views/index.ejs file into html page and sends it to the client. So, all logic runs on client-side. Your nodejs application just providing html page to the user. If you want to run speech recognition on server-side you can do one of next: 1. stream audio data from micro to server, and then recognize it on server. 2. save audio data on client-side until recording ends, and then send saved data to server, server will recognize it. (like audio file to text recognition) 3. google about watson server-server speech recognition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM