Skip to content

Commit

Permalink
Initial import of sources (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
microsoftopensource authored and mahilleb-msft committed Dec 17, 2018
1 parent 6478fd8 commit 384e49a
Show file tree
Hide file tree
Showing 142 changed files with 28,172 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
@@ -1,8 +1,14 @@
.gitattributes text
.gitignore text
.npmignore text
LICENSE text

*.cmd text
*.js text
*.json text
*.md text
*.ts text
*.txt text
*.yml text

# Bash only with Unix line endings
Expand Down
12 changes: 12 additions & 0 deletions .gitignore
@@ -0,0 +1,12 @@
# ignore the npm packages
/**/node_modules/
# ignore auto-generated (transpiled) js files
src/**/*.js
tests/**/*.js
distrib/*
secrets/*
/**/speech.key
.idea/
test-javascript-junit.xml
coverage/*
*.tgz
8 changes: 8 additions & 0 deletions .npmignore
@@ -0,0 +1,8 @@
/.vscode/*
/node_modules/*
/.gitattributes
/.gitignore
/.npmignore
/.npmrc
/.vscode
/web.config
57 changes: 57 additions & 0 deletions BuildTestConfig.cmd
@@ -0,0 +1,57 @@
@REM Copyright (c) Microsoft Corporation. All rights reserved.
@REM Licensed under the MIT license.
@echo off
setlocal
if "%~1" equ "/?" goto :Usage
if "%~1" equ "-?" goto :Usage
if "%~1" equ "?" goto :Usage
if "%~1" equ "/h" goto :Usage
if "%~1" equ "-h" goto :Usage

set TEST_SETTING_FILE_DIR=%~dp0\secrets
if NOT EXIST "%TEST_SETTING_FILE_DIR%" (
md "%TEST_SETTING_FILE_DIR%" || (
echo Error creating directory %TEST_SETTING_FILE_DIR%
exit /b 1
)
)

set TEST_SETTING_FILE_NAME=%TEST_SETTING_FILE_DIR%\TestConfiguration.ts

if EXIST "%TEST_SETTING_FILE_NAME%" (
echo Clearing values from settings file.
echo. > "%TEST_SETTING_FILE_NAME%" || (
echo Error creating file %TEST_SETTING_FILE_NAME%
exit /b 1
)
)

@echo import { Settings } from "../tests/Settings" > "%TEST_SETTING_FILE_NAME%"

:NextArg
if "%~1" == "" (
goto :eof
)

for /f "tokens=1,2 delims=:" %%I in ("%~1") do (
echo Setting Settings.%%I = "%%J"
echo Settings.%%I = "%%J"; >> "%TEST_SETTING_FILE_NAME%"
)

shift
goto :NextArg

exit /b 0

:Usage
@echo off
echo.
echo Usage: %~n0 ^<ParamName^>:^<Value^>
echo.
echo Writes any ^<ParamName^>:^<Value^> pair to the test settings file for JavaScript bindings tests.
echo.
echo The file will be erased before new values are added.
echo.
echo Current settings available are: [SpeechSubscriptionKey:^<key^>] [SpeechRegion:^<region^>] [LuisSubscriptionKey:^<LuisKey^>] [LuisRegion:^<region^>] [LuisAppId:^<LuisAppId^>]
echo.
exit /b 1
27 changes: 10 additions & 17 deletions LICENSE
@@ -1,21 +1,14 @@
MIT License
------------------------------------------- START OF LICENSE -----------------------------------------
Microsoft Azure Cognitive Services Speech SDK Javascript
Copyright (c) Microsoft Corporation
All rights reserved.

Copyright (c) Microsoft Corporation. All rights reserved.
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

----------------------------------------------- END OF LICENSE ------------------------------------------
74 changes: 73 additions & 1 deletion README.md
@@ -1,5 +1,77 @@
# Microsoft Cognitive Services Speech SDK for JavaScript

# Contributing
Visit https://aka.ms/csspeech.

## Build the project

To build the project you need to install the required packages, and then run the actual build.

### Install the required packages

Installation of the required packages is required once in your enlistment. Our automated build restores the packages with the following command:

```
npm ci
```

This will install packages exactly matching the package configuration from `package-lock.json`.

In a development environment you can also use the following command:

```
npm install
```

### Run the build

Once the dependencies are installed run the build by

```
npm run build
```

or

```
npx gulp bundle
```

or

```
npx gulp compress
```

> Note: `npx` is packaged with NPM 5.2 or above. Update NPM / Node if you
> don't have it or install it globally with `npm install -g npx` (less
> preferable).
## Data / Telemetry

This project collects data and sends it to Microsoft to help monitor our
service performance and improve our products and services. Read the [Microsoft
Privacy Statement](https://aka.ms/csspeech/privacy) to learn more.

To disable telemetry, you can call the following API:

```javascript
// disable telemetry data
sdk.Recognizer.enableTelemetry(false);
```

This is a global setting and will disable telemetry for all recognizers
(already created or new recognizers).

We strongly recommend you keep telemetry enabled. With telemetry enabled you
transmit information about your platform (operating system and possibly, Speech
Service relevant information like microphone characteristics, etc.), and
information about the performance of the Speech Service (the time when you did
send data and when you received data). It can be used to tune the service,
monitor service performance and stability, and might help us to analyze
reported problems. Without telemetry enabled, it is not possible for do any
form of detailed analysis in case of a support request.

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
Expand Down
7 changes: 7 additions & 0 deletions REDIST.txt
@@ -0,0 +1,7 @@
The following libraries can be redistributed if you are using the Cognitive
Services Speech SDK for JavaScript, subject to its license:

microsoft.cognitiveservices.speech.sdk.bundle.js
microsoft-cognitiveservices-speech-sdk NPM library

Depending on your usage, you only need to redistribute a subset of the above.
53 changes: 53 additions & 0 deletions RunTests.cmd
@@ -0,0 +1,53 @@
@REM Copyright (c) Microsoft Corporation. All rights reserved.
@REM Licensed under the MIT license.
@echo off
setlocal
if "%~1" equ "/?" goto :Usage
if "%~1" equ "-?" goto :Usage
if "%~1" equ "?" goto :Usage
if "%~1" equ "/h" goto :Usage
if "%~1" equ "-h" goto :Usage

set TEST_SETTING_FILE_NAME=%~dp0\secrets\TestConfiguration.ts

set TEST_SETTING_FILE_EXISTED=0
if EXIST "%TEST_SETTING_FILE_NAME%" set TEST_SETTING_FILE_EXISTED=1

if "%~1" NEQ "" (
call "%~dp0BuildTestConfig.cmd" %* || (
echo Error creating test config.
exit /b 1
)
) else if %TEST_SETTING_FILE_EXISTED% EQU 0 (
echo Warning: No test config and no parameters specified. This will probably fail. 1>&2
)

pushd "%~dp0"
call npm run test

set NPM_ERROR=%ERRORLEVEL%

if %TEST_SETTING_FILE_EXISTED% EQU 0 (
del "%TEST_SETTING_FILE_NAME%"
)

popd

exit /b %NPM_ERROR%

@REM TODO fix usage
:Usage
@echo off
echo.
echo Usage: %~n0 [^<ParamName^>:^<Value^>]
echo.
echo Writes any ^<ParamName^>:^<Value^> pair to the test settings file for JavaScript bindings tests.
echo.
echo The file will be erased before new values are added.
echo.
echo If no values are specified, the existing file will not be modified.
echo.
echo Current settings available are: [SpeechSubscriptionKey:^<key^>] [SpeechRegion:^<region^>] [LuisSubscriptionKey:^<LuisKey^>] [LuisRegion:^<region^>] [LuidAppId:^<LuisAppId^>]
echo.
echo Once settings are written, executes the JS unit tests and if the settings file was created, it will be deleted.
exit /b 1
1 change: 1 addition & 0 deletions _config.yml
@@ -0,0 +1 @@
theme: jekyll-theme-minimal
5 changes: 5 additions & 0 deletions bundleApp.js
@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

window.SpeechSDK = require('./distrib/lib/microsoft.cognitiveservices.speech.sdk.js');

8 changes: 8 additions & 0 deletions ci/build.yml
Expand Up @@ -13,6 +13,9 @@ resources:
- repo: self
clean: true

variables:
SPEECHSDK_JS_ROOT: .

jobs:

- job: Pre
Expand All @@ -22,3 +25,8 @@ jobs:
steps:
- bash: ./ci/check-git-head.sh
displayName: Repository checks

- template: jsbuild.yml
parameters:
dependsOn: Pre
condition: true
72 changes: 72 additions & 0 deletions ci/jsbuild.yml
@@ -0,0 +1,72 @@
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
#

parameters:
dependsOn: ''
condition: succeeded()

jobs:

- job: JsBuild
dependsOn: ${{ parameters.dependsOn }}
condition: ${{ parameters.condition }}
pool:
name: Hosted VS2017
demands: npm
timeoutInMinutes: 60
steps:
- bash: npm ci && npm run civersion
displayName: Set version
workingDirectory: $(SPEECHSDK_JS_ROOT)
- bash: |
F=$(SPEECHSDK_JS_ROOT)/src/common.speech/RecognizerConfig.ts
[[ -f $F ]] || exit 1
perl -i.bak -p -e 'BEGIN { $c = 0 } $c += s/(?<=const SPEECHSDK_CLIENTSDK_VERSION = ")[^"]*/$(SPEECHSDK_SEMVER2NOMETA)/g; END { die "Patched SPEECHSDK_CLIENTSDK_VERSION $c time(s), expected 1.\n" if $c != 1 }' "$F"
E=$?
rm -f "$F.bak"
git diff
exit $E
displayName: Stamp SPEECHSDK_CLIENTSDK_VERSION
- bash: npm run build && npm pack
displayName: Build and pack SDK
workingDirectory: $(SPEECHSDK_JS_ROOT)
- script: |
RunTests.cmd ^
SpeechSubscriptionKey:$(speech-ne-s0-key1) ^
SpeechRegion:northeurope ^
LuisSubscriptionKey:$(luis-westus-s0-201809-key1) ^
LuisRegion:westus ^
SpeechTestEndpointId:ec3432b2-8584-4736-865a-556213b9f6fd
displayName: Run tests
workingDirectory: $(SPEECHSDK_JS_ROOT)
- task: PublishTestResults@2
displayName: Publish test results
- bash: |
set -u -e -o pipefail -x
PACKAGE_BASE=microsoft-cognitiveservices-speech-sdk
PACKAGE_NAME=$PACKAGE_BASE-$SPEECHSDK_SEMVER2NOMETA.tgz
PACKAGE_IN=$(SPEECHSDK_JS_ROOT)/$PACKAGE_NAME
PACKAGE_OUT="$(Build.ArtifactStagingDirectory)/Out/JavaScript/npm"
ZIP_OUT="$(Build.ArtifactStagingDirectory)/Out/JavaScript/SpeechSDK-JavaScript-$SPEECHSDK_SEMVER2NOMETA"
mkdir -p "$PACKAGE_OUT" "$ZIP_OUT"
cp --preserve "$PACKAGE_IN" "$PACKAGE_OUT"
echo SRI hash for microsoft.cognitiveservices.speech.sdk.bundle.js: sha512-"$(openssl dgst -sha512 -binary $(SPEECHSDK_JS_ROOT)/distrib/browser/microsoft.cognitiveservices.speech.sdk.bundle.js | openssl base64 -A)"
cp --preserve $(SPEECHSDK_JS_ROOT)/LICENSE $(SPEECHSDK_JS_ROOT)/REDIST.txt $(SPEECHSDK_JS_ROOT)/distrib/browser/microsoft.cognitiveservices.speech.sdk.bundle.* $(SPEECHSDK_JS_ROOT)/distrib/browser/microsoft.cognitiveservices.speech.sdk.bundle-min.* "$ZIP_OUT"
displayName: Create drop
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Build.ArtifactStagingDirectory)/Out/JavaScript/SpeechSDK-JavaScript-$(SPEECHSDK_SEMVER2NOMETA)
includeRootFolder: true
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/Out/JavaScript/SpeechSDK-JavaScript-$(SPEECHSDK_SEMVER2NOMETA).zip
displayName: Create .zip
- bash: rm -rf "$(Build.ArtifactStagingDirectory)/Out/JavaScript/SpeechSDK-JavaScript-$(SPEECHSDK_SEMVER2NOMETA)"
displayName: Remove temporary directory
- task: PublishBuildArtifacts@1
displayName: Publish drop
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/Out/JavaScript'
ArtifactName: JavaScript
publishLocation: Container

0 comments on commit 384e49a

Please sign in to comment.