bingspeech api client
3.1.0
Microsoft Bing語音API客戶端用Node.J。
Bing語音API服務的官方文件。
要使用Bing Speech API,您必須有一個訂閱密鑰。如果您還沒有訂閱密鑰,請在此處獲取一個:訂閱。
使用NPM安裝節點項目中的bingspeech-api-client 。
npm install --save bingspeech-api-client
請參閱下面的示例,介紹如何和語音使用文本(STT)和文本到語音(TTS)。
以下示例代碼假設您正在使用Typescript。如果是,請跳過本節,直接進入示例。但是,如果您使用的是節點ES6,並且想使用示例代碼讀取。
目前,節點不支持import 。如MDN
注意:此功能剛剛在此時才開始在瀏覽器中
import。它是在許多轉下器中實現的,例如Traceur編譯器,Babel,Collup或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 => /* ... */ ) ;