Describe the bug
Running under node and trying to use AudioConfig.fromWavFileInput fails due to it trying to use FileReader which is not available in node.
To Reproduce
Steps to reproduce the behavior:
npm install microsoft-cognitiveservices-speech-sdkconst sdk = require("microsoft-cognitiveservices-speech-sdk");
const audioConfig = sdk.AudioConfig.fromWavFileInput("sample.wav");
This will fail with:
node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/FileAudioSource.js:72
var headerReader = new FileReader();
^
ReferenceError: FileReader is not defined
Expected behavior
It should load the wave file successfully when running in node.
Version of the Cognitive Services Speech SDK
1.13.1
Platform, Operating System, and Programming Language
Additional context
node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/FileAudioSource.js:72
var headerReader = new FileReader();
^
ReferenceError: FileReader is not defined
I'm also experiencing this issue, any help would be appreciated.
@cgreening, @mkral AudioConfig.fromWavFileInput is currently not supported for node. We do have an open item to support that method in a future release. I looked at the Speech-to-Text quickstart in Azure Docs, and was surprised to find bad information there about fromWavFileInput. To create an inputStream for audioConfig, please use the following:
var sdk = require("microsoft-cognitiveservices-speech-sdk");
var fs = require("fs")
var filename = "<<FILENAME>>"; // 16000 Hz, Mono
// create the push stream we need for the speech sdk.
var pushStream = sdk.AudioInputStream.createPushStream();
// open the file and push it to the push stream.
fs.createReadStream(filename).on('data', function(arrayBuffer) {
pushStream.write(arrayBuffer.slice());
}).on('end', function() {
pushStream.close();
});
var audioConfig = sdk.AudioConfig.fromStreamInput(pushStream);
I apologize for the incorrect info in the docs, and have opened an issue with the docs team to get it corrected ASAP.
Thanks,
Glenn
Most helpful comment
@cgreening, @mkral AudioConfig.fromWavFileInput is currently not supported for node. We do have an open item to support that method in a future release. I looked at the Speech-to-Text quickstart in Azure Docs, and was surprised to find bad information there about fromWavFileInput. To create an inputStream for audioConfig, please use the following:
I apologize for the incorrect info in the docs, and have opened an issue with the docs team to get it corrected ASAP.
Thanks,
Glenn