2017-02-07 7 views
4

Google Speech APIのNode.JSバリエーションを使用しています。Node.JSのGoogleクラウドスピーチ:config speech_context

私は冗談文字列speech_contextの配列を渡すまでうまく、ダンディーはすべて動作します。以下の各方法で試してみると、ストリームは中断しますが、エラーはありませんが出力されます。したがって、診断する方法はありません。

文字列["one", "two", "three"]を渡しており、the documentationに準拠していると思います。私の元の構成は次のようになります。

const cf = { 
    config: { 
     encoding: 'LINEAR16', 
     sampleRate: 48000 
    } 
} 

私はcf.config.speech_context = ARRAYcf.config.speech_context.phrases = ARRAYcf.speech_context = ARRAY、およびcf.speech_context.phrases = ARRAYを試してみました。

また、エラーメッセージも表示されず、結果も表示されません。私は何も得られない。オリジナルの設定はです。

recognizeStream = speech.createRecognizeStream(cf) 
    .on('error', console.error) 
    .on('data', console.log) 

アイデア:基本的な流れと

これ?どんな助けも非常に高く評価されるでしょう!

答えて

0
const request = { 
    config: { 
     encoding: encoding, 
     sampleRate: sampleRate, 
     languageCode:'en-IN-x-longform', 
    } 
    }; 

    // Stream the audio to the Google Cloud Speech API 

    const recognizeStream = speech.createRecognizeStream(request) 
    .on('error', (error) => { 
     console.error; 
    }) 
    .on('data', (data) => { 
     console.log('Data received: %j', data); 
     if('results' in data) 
     console.log(chalk.bgYellow(data.results)); 
     logger.log(JSON.stringify(data)); 
    }); 



    // Stream an audio file from disk to the Speech API, e.g. "./resources/audio.raw" 

    filename = "./resources/audio.raw"; 
    fs.createReadStream(filename).pipe(recognizeStream); 



//This is working for me 
//I think you are missing the pipe part in , so you can do 

recognizeStream = speech.createRecognizeStream(cf) 
     .on('error', console.error) 
     .on('data', console.log) 

    filename = "./resources/audio.raw"; 
    fs.createReadStream(filename).pipe(recognizeStream); 

` 
関連する問題