{"library":"microsoft-cognitiveservices-speech-sdk","title":"Microsoft Azure Cognitive Services Speech SDK for JavaScript","description":"The Microsoft Cognitive Services Speech SDK for JavaScript provides robust APIs for integrating speech-to-text, text-to-speech, and speech translation capabilities into JavaScript applications. It supports both browser and Node.js environments, making it versatile for various use cases. The current stable version is 1.49.0, with a release cadence that appears to be monthly or bi-monthly, indicating active development and continuous feature enhancements. Key differentiators include official support for Azure Speech Services, comprehensive feature set for speech AI, and first-class TypeScript type definitions, enabling a more robust development experience compared to generic WebSocket or REST API integrations.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install microsoft-cognitiveservices-speech-sdk"],"cli":null},"imports":["import { SpeechConfig } from 'microsoft-cognitiveservices-speech-sdk';","import { SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';","import { AudioConfig } from 'microsoft-cognitiveservices-speech-sdk';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { SpeechConfig, AudioConfig, SpeechRecognizer, ResultReason } from 'microsoft-cognitiveservices-speech-sdk';\n\nconst speechKey: string = process.env.SPEECH_KEY ?? '';\nconst speechRegion: string = process.env.SPEECH_REGION ?? '';\n\nasync function recognizeFromMicrophone(): Promise<void> {\n    if (!speechKey || !speechRegion) {\n        console.error('Please set the SPEECH_KEY and SPEECH_REGION environment variables.');\n        return;\n    }\n\n    const speechConfig = SpeechConfig.fromSubscription(speechKey, speechRegion);\n    speechConfig.speechRecognitionLanguage = 'en-US';\n\n    const audioConfig = AudioConfig.fromDefaultMicrophoneInput();\n    const recognizer = new SpeechRecognizer(speechConfig, audioConfig);\n\n    console.log('Say something into your microphone...');\n\n    recognizer.recognizeOnceAsync(result => {\n        switch (result.reason) {\n            case ResultReason.RecognizedSpeech:\n                console.log(`RECOGNIZED: Text=${result.text}`);\n                break;\n            case ResultReason.NoMatch:\n                console.log('NOMATCH: Speech could not be recognized.');\n                break;\n            case ResultReason.Canceled:\n                const cancellationDetails = result.cancellationDetails;\n                console.log(`CANCELED: Reason=${cancellationDetails?.reason}`);\n                if (cancellationDetails?.errorDetails) {\n                    console.log(`CANCELED: ErrorDetails=${cancellationDetails.errorDetails}`);\n                }\n                break;\n        }\n    });\n}\n\nrecognizeFromMicrophone();","lang":"typescript","description":"Demonstrates basic speech-to-text recognition from microphone input, showing how to configure the SDK, listen for speech, and process the recognized text or cancellation events.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}