Can't convert .wav file to text by Wit.speech() method
MarkZhinkin opened this issue · 2 comments
MarkZhinkin commented
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 commented
maybe because you're using 'audio/mpeg instead of audio/wav?
MarkZhinkin commented
@Rit-tan Thanks, it work. Close the issues