عميل Microsoft Bing Counter API مكتوب في Node.js.
الوثائق الرسمية لخدمة API Bing Counter.
للعمل مع Bing Pleint API ، يجب أن يكون لديك مفتاح اشتراك. إذا لم يكن لديك مفتاح اشتراك بالفعل ، احصل على واحد هنا: الاشتراكات.
تثبيت bingspeech-api-client في مشروع العقدة الخاص بك مع NPM.
npm install --save bingspeech-api-client
انظر مثال أدناه حول كيفية طلب واستخدام الكلام إلى رسالة نصية (STT) والنص على الكلام (TTS).
يلي مثال رمز يفترض أنك تستخدم TypeScript. إذا كنت كذلك ، تخطي هذا القسم وانتقل مباشرة إلى الأمثلة. ولكن إذا كنت تستخدم Node ES6 وتريد استخدام رمز المثال ، فاقرأ.
في الوقت الحاضر لا تدعم import . كما ذكر في MDN
ملاحظة: تبدأ هذه الميزة [
import] فقط في المتصفحات أصليًا في هذا الوقت. يتم تنفيذه في العديد من أجهزة الاستقبال ، مثل برنامج التحويل البرمجي Traceur أو 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 => /* ... */ ) ;