Can't convert .wav file to text by Wit.speech() method

This issue has been tracked since 2022-04-17.

Hi, I'm try to convert users audiomessages to text and then give some answer.

I try to migrate from pywit to node-wit.

In python I use this code:

from wit import Wit

client = Wit("MY_WIT_KEY")
resp = None
with open('4.wav', 'rb') as f:
    resp = client.speech(f, {'Content-Type': 'audio/wav'})
print(resp)

and it's work.

But if i try to send the same audiofile with node.js I always get empty result.

const {Wit} = require('node-wit');
const fs = require('fs');


const client = new Wit({accessToken: 'MY_WIT_KEY'});
var pathToFile = '.\\4.wav'
const data = fs.readFileSync(pathToFile);

client.speech('audio/mpeg', data)
.then(data => {
    console.log(JSON.stringify(data));
})
.catch(console.error);

I use this audio which I convert to .wav to test my code.

node-wit 6.2.1
node 12.22
Rit-tan wrote this answer on 2022-04-27

maybe because you're using 'audio/mpeg instead of audio/wav?

MarkZhinkin wrote this answer on 2022-04-27

@Rit-tan Thanks, it work. Close the issues

More Details About Repo
Owner Name wit-ai
Repo Name node-wit
Full Name wit-ai/node-wit
Language JavaScript
Created Date 2016-04-12
Updated Date 2022-12-02
Star Count 1928
Watcher Count 98
Fork Count 497
Issue Count 36

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date