bingspeech api client
3.1.0
node.jsで書かれたMicrosoft Bing Speech APIクライアント
Bing Speech APIサービスの公式ドキュメント。
Bing Speech APIを使用するには、サブスクリプションキーが必要です。まだサブスクリプションキーがない場合は、ここで入手してください:サブスクリプション。
NPMでノードプロジェクトにbingspeech-api-clientをインストールします。
npm install --save bingspeech-api-client
以下の例を参照してください。テキスト(STT)とテキストからスピーチ(TTS)の要求と使用方法を参照してください。
次の例コードは、TypeScriptを使用していると仮定しています。もしそうなら、このセクションをスキップして、例に直接進みます。ただし、ノードES6を使用していて、読み取りのサンプルコードを使用する場合。
現在、ノードはimportをサポートしていません。 MDNで述べたように
注:この機能[
import]は、現時点でブラウザにネイティブに実装され始めたばかりです。 Traceur Compiler、Babel、Rollup、Webpackなど、多くのトランスピラーに実装されています。
サンプルコードを動作させるには、最初の行を変更します。
const { BingSpeechClient , VoiceRecognitionResponse } = require ( 'bingspeech-api-client' ) ; import { BingSpeechClient , VoiceRecognitionResponse } from 'bingspeech-api-client' ;
let audioStream = fs . createReadStream ( myFileName ) ; // create audio stream from any source
// Bing Speech Key (https://www.microsoft.com/cognitive-services/en-us/subscriptions)
let subscriptionKey = 'your_private_subscription_key' ;
let client = new BingSpeechClient ( subscriptionKey ) ;
client . recognizeStream ( audioStream ) . then ( response => console . log ( response . results [ 0 ] . name ) ) ; import { BingSpeechClient , VoiceVoiceSynthesisResponse } from 'bingspeech-api-client' ;
// Bing Speech Key (https://www.microsoft.com/cognitive-services/en-us/subscriptions)
let subscriptionKey = 'your_private_subscription_key' ;
let client = new BingSpeechClient ( subscriptionKey ) ;
client . synthesizeStream ( 'I have a dream' ) . then ( audioStream => /* ... */ ) ;