Not all voice files give output from Google Speech to Text API for Node.js -


i using below node.js script snippet,

'use strict'; var google_speech = require('google-speech'); google_speech.asr({     debug: true,     lang: 'en_us',     developer_key: '<google api key>',     file: '<voice file name path>',   }, function(err, httpresponse, xml){        if(err){         console.log(err);       }else{         console.log(httpresponse.statuscode, xml)       }     } ); 

the output getting audio files not all. example 1 flac file giving output flac file doesn't.

is there specific type of files required api give output. if yes, let me know specific type/format of file.

if you're using this google-speech node library, appears it's hardcoded content-type header audio/l16; rate=16000 here in source code.

it looks can overridden option in first param, so, example, if you're using 44.1khz flac file, following might work

'use strict'; var google_speech = require('google-speech'); google_speech.asr({     debug: true,     lang: 'en_us',     developer_key: '<google api key>',     file: '<voice file name path>',     'content-type': 'audio/x-flac; rate=44100' // ← override here   }, function(err, httpresponse, xml){        if(err){         console.log(err);       }else{         console.log(httpresponse.statuscode, xml)       }     } ); 

that being said (and wasn't asked), appear google's updated official cloud speech api, may find useful. they've got nodejs tutorial here, , more extensive details about file formats supported here.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -