Reputation: 69
I have developed Microsoft bot framework node js bot and connected to Facebook. When I am trying to add speech service to bot using facebook mic, am getting below error.
I have gone through the link sample code but getting below error when I am giving voice input through FB mic.
Error: ENOENT: no such file or directory, open 'D:\home\site\wwwroot\https:\cdn.fbsbx.com\'
below is the code snippet, function "fs.createReadStream()" generating error:
async function openPushStream(filename) {
// create the push stream we need for the speech sdk.
console.log('---from open push stream funcion ----',filename);
var pushStream = sdk.AudioInputStream.createPushStream();
// open the file and push it to the push stream.
request(filename).pipe(fs.createWriteStream('userInputVoice.wav'))
fs.createReadStream(filename).on('data', function(arrayBuffer) {
pushStream.write(arrayBuffer.buffer);
}).on('end', function() {
pushStream.close();
});
var audioConfig = sdk.AudioConfig.fromStreamInput(pushStream);
var speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion);
// Setting the recognition language to English.
speechConfig.speechRecognitionLanguage = "en-US";
// Create the speech recognizer.
var recognizer = new sdk.SpeechRecognizer(speechConfig, audioConfig);
recognizer.recognizeOnceAsync(
function (result) {
console.log(result);
recognizer.close();
recognizer = undefined;
return result;
},
function (err) {
console.trace("err - " + err);
recognizer.close();
recognizer = undefined;
});
return null;
}
Please suggest, how to handle this issue. Thanks in advance.
I look forward for your response/suggestions.
Upvotes: 0
Views: 114
Reputation: 6393
You can control the path value that is read from the created stream by passing the fd
property in as an option when you call fs.createReadStream
(you can read more about it here). Setting it to 0
tells the system not to pre-pend the stream path with the local pathway. Be aware that the open
event will not be called when fd
is passed in.
When tested, this unblocked my code. I was receiving the same error due to a similar pre-pended path as you (e.g. "c:\...\...\https:\someSite.com\someFile").
let readStream = fs.createReadStream(inputStream, {
fd: 0
});
Adjusting your code to this should work for you.
request(filename).pipe(fs.createWriteStream('userInputVoice.wav', {
fd: 0
}))
Hope of help!
Upvotes: 1