• United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.206

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

watson speech to text error in node.js

310001WRTA gravatar image
Question by Joe_Yang  (44) | Sep 07, 2018 at 12:48 PM ibm-cloudwatsonwatson-assistantwatson services

I have been getting stuck on my speech_to_text test for a couple of days, any advice would be appreciated:

WARNING: This method of instantiating the Watson services has been deprecated beginning with Version 3.0.0 of the Node SDK. Please refer to the Node SDK documentation for information on how to instantiate Watson services. This form of service instantiaion will be removed in a future release of the SDK. start record Error: Watson Speech to Text RecognizeStream: the results event was deprecated. Please set {objectMode: true} and listen for the 'data' event instead. Pass {silent: true} to disable this message. at RecognizeStream. (/home/pi/workspace/rapiro-iotf/node_modules/watson-developer-cloud/lib/recognize-stream.js:128:33) at RecognizeStream.emit (events.js:180:13) at _addListener (events.js:209:14) at RecognizeStream.addListener (events.js:258:10) at RecognizeStream.Readable.on (_stream_readable.js:784:35) at stt (/home/pi/workspace/rapiro-iotf/mictest.js:32:18) at Object. (/home/pi/workspace/rapiro-iotf/mictest.js:8:2) at Module._compile (internal/modules/cjs/loader.js:654:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10) at Module.load (internal/modules/cjs/loader.js:566:32) Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono

Here's my source code:

 var watson = require('watson-developer-cloud');
 var cp = require('child_process');
 var mic;
 var fs = require('fs');
 mic = cp.spawn('arecord', ['--device=plughw:1,0', '--format=S16_LE', '--rate=44100', 
          '--channels=1']); //, '--duration=10'
  mic.stderr.pipe(process.stderr);
  stt();
 
  function stt() {
   console.log("openCMDS");
   var speech_to_text = watson.speech_to_text({
   username: 'myusername',
   password: 'mypassword', 
   version: 'v1'
   });


 var params = {
 content_type: 'audio/wav',
 model:'zh-CN_BroadbandModel',
 continuous: true,
     objectMode: true,
 inactivity_timeout: -1
 };

 recognizeStream = speech_to_text.createRecognizeStream(params);
     mic.stdout.pipe(require('fs').createWriteStream('test.wav'));
     mic.stdout.pipe(recognizeStream);
 recognizeStream.setEncoding('utf8'); 
 console.log("start record");
 recognizeStream.on('results',  function(data){
 
 if(data.results[0] && data.results[0].final && data.results[0].alternatives){
         
     console.log(JSON.stringify(data, null, 2));
     
     }
  });

 }

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

3 answers

  • Sort: 
310001WRTA gravatar image

Answer by Joe_Yang (44) | Sep 09, 2018 at 08:13 AM

the error is gone after following new stt api, In particular I was trying to get the microphone streamed directly to the speechToText service. I believe this is the most common way of using mic, not piping it into a .wav and then stream the .wav file to stt., any advice ?

 var mic;
 var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
 var fs = require('fs');
 var watson = require('watson-developer-cloud');
 var cp = require('child_process');
  mic = cp.spawn('arecord', ['--device=plughw:1,0', '--format=S16_LE', '--rate=44100', '--channels=1']); //, '--duration=10'
  mic.stderr.pipe(process.stderr);
  stt();
  
  function stt() {
     console.log("openCMDS");
         var speech_to_text = new SpeechToTextV1({
         username: '',
         password: ''
         });

     var params = {
     content_type: 'audio/wav',
     model: 'zh-CN_BroadbandModel',
     continuous: true,
     inactivity_timeout: -1
     };

     recognizeStream = speech_to_text.createRecognizeStream(params);
         mic.stdout.pipe(recognizeStream);
         //mic.stdout.pipe(require('fs').createWriteStream('test.wav')); 
  
         // Pipe in the audio.
         fs.createReadStream('test.wav').pipe(recognizeStream);
         recognizeStream.pipe(fs.createWriteStream('transcription.txt'));

     recognizeStream.setEncoding('utf8'); 
     console.log("start record");
        recognizeStream.on('data', function(event) { onEvent('Data:', event); });
        recognizeStream.on('error', function(event) { onEvent('Error:', event); });
        recognizeStream.on('close', function(event) { onEvent('Close:', event); });

 // Display events on the console.
 function onEvent(name, event) {
     console.log(name, JSON.stringify(event, null, 2));
      }
         
 }
Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
310001WRTA gravatar image

Answer by Joe_Yang (44) | Sep 10, 2018 at 11:38 AM

any solution would be appreciated ;)

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
310001WRTA gravatar image

Answer by Joe_Yang (44) | Sep 11, 2018 at 11:16 PM

I also created a question on stackoverflow: https://stackoverflow.com/questions/52286957/how-to-get-the-microphone-streamed-directly-to-the-watson-speechtotext-service

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

151 people are following this question.

Answers

Answers & comments

Related questions

node.js - speech to text deprecated error 0 Answers

watson speech to text error on node.js 0 Answers

After Digression how to don't ask previous question and continue further where stopped before? 2 Answers

Connection problem using web API via z/OS Client Web Enablement Toolkit using PL1 0 Answers

[IBM Watson] 403 authentication error when connecting to a workspace 1 Answer

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • DataPower
  • Decision Optimization
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges