palmerabollo / bingspeech-api-client

Microsoft Bing Speech API client in node.js
Other
32 stars 17 forks source link

Unable to assign fs.ReadStream to NodeJS.ReadWriteStream #17

Closed betterclever closed 6 years ago

betterclever commented 7 years ago

As per the README,

I created a new ReadStream by

let audioStream = fs.createReadStream(myFileName);

then in

let client = new BingSpeechClient(subscriptionKey);
client.recognizeStream(audioStream).then(response => console.log(response.results[0].name));

recognizeStream method, the type expected is NodeJS.ReadWriteStream but audioStream is fs.ReadStream, though I found that NodeJS.ReadWriteStream extends both ReadableStream and WriteableStream, but still I am getting error in Typescript transpiler.

 TS2345: Argument of type 'ReadStream' is not assignable to parameter of type 'ReadWriteStream'.
  Types of property 'setEncoding' are incompatible.
    Type '(encoding: string) => ReadStream' is not assignable to type '(encoding: string) => ReadWriteStream'.
      Type 'ReadStream' is not assignable to type 'ReadWriteStream'.

Can you suggest what can I do?

j-hiertz commented 7 years ago

Not a real solution but :

let audioStream:any = fs.createReadStream(myFileName); works for me.

palmerabollo commented 6 years ago

Thanks @Tsuuki