-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update NodeJS Quickstarts/Samples to 1.11.0 (#570)
- Loading branch information
Showing
14 changed files
with
384 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
40 changes: 19 additions & 21 deletions
40
quickstart/javascript/node/package-lock.json → ...vascript/node/from-file/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Quickstart: Synthesize speech in JavaScript on Node.js. | ||
|
||
This sample demonstrates how to synthesize speech with the Speech SDK for JavaScript on Node.js. | ||
|
||
## Prerequisites | ||
|
||
* A subscription key for the Speech service. See [Try the speech service for free](https://docs.microsoft.com/azure/cognitive-services/speech-service/get-started). | ||
* A [Node.js](https://nodejs.org) compatible device. | ||
|
||
## Prepare the sample | ||
|
||
* [Download the sample code to your development PC.](/README.md#get-the-samples) | ||
* Open a command prompt at the quickstart directory, and run `npm install` to install the dependencies of the quickstart. | ||
This will place the Speech SDK library in the `node_modules` directory. | ||
* Update the `index.js` file with your configuration: | ||
* Replace the string `YourSubscriptionKey` with your own subscription key. | ||
* Replace the string `YourServiceRegion` with the service region of your subscription. | ||
For example, replace with `westus` if you are using the 30-day free trial subscription. | ||
* Replace the string `YourAudioFile.wav` with a path you desire. | ||
|
||
## Run the sample | ||
|
||
Execute `node index.js` from the location where you have downloaded this quickstart. | ||
|
||
## References | ||
|
||
* [Speech SDK API reference for JavaScript](https://aka.ms/csspeech/javascriptref) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
(function() { | ||
// <code> | ||
"use strict"; | ||
|
||
// pull in the required packages. | ||
var sdk = require("microsoft-cognitiveservices-speech-sdk"); | ||
var readline = require("readline"); | ||
|
||
// replace with your own subscription key, | ||
// service region (e.g., "westus"), and | ||
// the name of the file you save the synthesized audio. | ||
var subscriptionKey = "YourSubscriptionKey"; | ||
var serviceRegion = "YourServiceRegion"; // e.g., "westus" | ||
var filename = "YourAudioFile.wav"; | ||
|
||
// we are done with the setup | ||
|
||
// now create the audio-config pointing to our stream and | ||
// the speech config specifying the language. | ||
var audioConfig = sdk.AudioConfig.fromAudioFileOutput(filename); | ||
var speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion); | ||
|
||
// create the speech synthesizer. | ||
var synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig); | ||
|
||
var rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
|
||
rl.question("Type some text that you want to speak...\n> ", function (text) { | ||
rl.close(); | ||
// start the synthesizer and wait for a result. | ||
synthesizer.speakTextAsync(text, | ||
function (result) { | ||
if (result.reason === sdk.ResultReason.SynthesizingAudioCompleted) { | ||
console.log("synthesis finished."); | ||
} else { | ||
console.error("Speech synthesis canceled, " + result.errorDetails + | ||
"\nDid you update the subscription info?"); | ||
} | ||
synthesizer.close(); | ||
synthesizer = undefined; | ||
}, | ||
function (err) { | ||
console.trace("err - " + err); | ||
synthesizer.close(); | ||
synthesizer = undefined; | ||
}); | ||
console.log("Now synthesizing to: " + filename); | ||
}); | ||
// </code> | ||
|
||
}()); | ||
|
136 changes: 136 additions & 0 deletions
136
quickstart/javascript/node/text-to-speech/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"private": true, | ||
"name": "speech-sdk-quickstart-node-tts", | ||
"version": "1.0.0", | ||
"description": "Text-to-speech quickstart for the Microsoft Speech SDK on Node.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Microsoft", | ||
"license": "MIT", | ||
"dependencies": { | ||
"https-proxy-agent": "^3.0.0", | ||
"microsoft-cognitiveservices-speech-sdk": "^1.11.0", | ||
"readline": "^1.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.