Skip to content

Commit

Permalink
Samples updates for the 1.8.0 release. (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMouncer authored Nov 8, 2019
1 parent 6805d96 commit 5436972
Show file tree
Hide file tree
Showing 712 changed files with 21,023 additions and 146 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ proguard-rules.pro text
*.mp3 binary
*.pfx binary
*.png binary
*.table binary
*.wav binary
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,8 @@ quickstart/csharp-unity/[Ll]ogs/

# Linux executables
quickstart/cpp-linux/helloworld
samples/cpp/windows/console/samples/sample
samples/cpp/windows/console/samples/sample

# macOS executables
quickstart/cpp-macos/helloworld
quickstart/text-to-speech/cpp-macos/helloworld
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ This project hosts the **samples** for the Microsoft Cognitive Services Speech S

Please check [here](https://aka.ms/csspeech/whatsnew) for release notes and older releases.

* Speech SDK Release 1.8.0

November 2019 we released version 1.8.0 of the Speech SDK

* Speech SDK Release 1.7.0

September 2019 we released version 1.7.0 of the Speech SDK
Expand Down Expand Up @@ -53,7 +57,7 @@ Please check [here](https://aka.ms/csspeech/whatsnew) for release notes and olde
This repository hosts samples that help you to get started with several features of the SDK.
In addition more complex scenarios are included to give you a head-start on using speech technology in your application.

We tested the samples with the latest released version of the SDK (1.7.0) on Windows 10, Linux (Ubuntu 16.04, Ubuntu 18.04, Debian 9), Android devices (API 23: Android 6.0 Marshmallow or higher), and iOS 11.4 devices.
We tested the samples with the latest released version of the SDK (1.6.0) on Windows 10, Linux (Ubuntu 16.04, Ubuntu 18.04, Debian 9), Android devices (API 23: Android 6.0 Marshmallow or higher), and iOS 11.4 devices.

## Getting Started

Expand Down Expand Up @@ -84,6 +88,7 @@ If you want to build them from scratch, please follow the articles in the Quicks
| ---------- | -------- | ----------- |
| [Quickstart C++ for Linux](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/cpp-linux/) | Linux | Demonstrates one-shot speech recognition from a microphone. |
| [Quickstart C++ for Windows](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/cpp-windows/) | Windows | Demonstrates one-shot speech recognition from a microphone. |
| [Quickstart C++ for macOS](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/cpp-macos/) | macOS | | Demonstrates one-shot speech recognition from a microphone. |
| [Quickstart C# .NET for Windows](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/csharp-dotnet-windows/) | Windows | Demonstrates one-shot speech recognition from a microphone. |
| [Quickstart C# .NET Core](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/csharp-dotnetcore/) | Windows, Linux, macOS | Demonstrates one-shot speech recognition from a microphone. |
| [Quickstart C# UWP for Windows](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/csharp-uwp/) | Windows | Demonstrates one-shot speech recognition from a microphone. |
Expand Down Expand Up @@ -120,6 +125,7 @@ If you want to build them from scratch, please follow the articles in the Quicks
| ---------- | -------- | ----------- |
| [Quickstart C++ for Linux](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/text-to-speech/cpp-linux/) | Linux | Demonstrates one-shot speech synthesis to the default speaker. |
| [Quickstart C++ for Windows](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/text-to-speech/cpp-windows/) | Windows | Demonstrates one-shot speech synthesis to the default speaker. |
| [Quickstart C++ for macOS](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/text-to-speech/cpp-macos) | macOS | Demonstrates one-shot speech synthesis to the default speaker. |
| [Quickstart C# .NET for Windows](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/text-to-speech/csharp-dotnet-windows/) | Windows | Demonstrates one-shot speech synthesis to the default speaker. |
| [Quickstart C# UWP for Windows](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/text-to-speech/csharp-uwp/) | Windows | Demonstrates one-shot speech synthesis to the default speaker. |
| [Quickstart C# .NET Core](https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/text-to-speech/csharp-dotnetcore/) | Windows, Linux | Demonstrates one-shot speech synthesis to the default speaker. |
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions quickstart/cpp/macos/text-to-speech/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
#
# Microsoft Cognitive Services Speech SDK - Quickstart for macOS and C++
#
# Check out https://aka.ms/csspeech for documentation.
#

SPEECHSDK_ROOT:=/change/to/point/to/extracted/SpeechSDK

CHECK_FOR_SPEECHSDK := $(shell test -f $(SPEECHSDK_ROOT)/MicrosoftCognitiveServicesSpeech.framework/MicrosoftCognitiveServicesSpeech && echo Success)
ifneq ("$(CHECK_FOR_SPEECHSDK)","Success")
$(error Please set SPEECHSDK_ROOT to point to your extracted Speech SDK, $$SPEECHSDK_ROOT/MicrosoftCognitiveServicesSpeech.framework/MicrosoftCognitiveServicesSpeech should exist.)
endif

LIBS:=-framework MicrosoftCognitiveServicesSpeech
all: helloworld

# Note: to run, DYLD_FRAMEWORK_PATH should point to $SPEECHSDK_ROOT.
helloworld: helloworld.cpp
g++ $< -o $@ \
--std=c++14 \
$(patsubst %,-F%, $(SPEECHSDK_ROOT)) \
$(LIBS)

51 changes: 51 additions & 0 deletions quickstart/cpp/macos/text-to-speech/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Quickstart: Synthesize speech in C++ for macOS

This sample demonstrates how to synthesize speech with C++ using the Speech SDK for macOS.
See the [accompanying article](https://docs.microsoft.com/azure/cognitive-services/speech-service/quickstart-text-to-speech-cpp-macos) on the SDK documentation page for step-by-step instructions.

## 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 Mac with a working speaker.

## Build the sample

* [Download the sample code to your development PC.](../../../README.md#get-the-samples)
* Download and extract the Speech SDK
* **By downloading the Microsoft Cognitive Services Speech SDK, you acknowledge its license, see [Speech SDK license agreement](https://aka.ms/csspeech/license201809).**
* Run the following commands after replacing the string `/your/path` with a directory (absolute path) of your choice:

```sh
export SPEECHSDK_ROOT="/your/path"
mkdir -p "$SPEECHSDK_ROOT"
wget -O MicrosoftCognitiveServicesSpeech.framework.zip https://aka.ms/csspeech/macosbinary
tar --strip 1 -xzf MicrosoftCognitiveServicesSpeech.framework.zip -C "$SPEECHSDK_ROOT"
```

* Navigate to the directory of this sample
* Edit the file `Makefile`:
* In the line `SPEECHSDK_ROOT:=/change/to/point/to/extracted/SpeechSDK` change the right-hand side to point to the location of your extracted Speech SDK framework.
* Edit the `helloworld.cpp` source:
* 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.
* Run the command `make` to build the sample, the resulting executable will be called `helloworld`.

## Run the sample

To run the sample, you'll need to configure the loader's library path to point to the Speech SDK library.

```sh
export DYLD_FRAMEWORK_PATH="DYLD_FRAMEWORK_PATH:$SPEECHSDK_ROOT"
```

Run the application:

```sh
./helloworld
```

## References

* [Quickstart article on the SDK documentation site](https://docs.microsoft.com/azure/cognitive-services/speech-service/quickstart-text-to-speech-cpp-macos)
* [Speech SDK API reference for C++](https://aka.ms/csspeech/cppref)
58 changes: 58 additions & 0 deletions quickstart/cpp/macos/text-to-speech/helloworld.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//

// <code>
#include <iostream> // cin, cout
#include <MicrosoftCognitiveServicesSpeech/speechapi_cxx.h>

using namespace std;
using namespace Microsoft::CognitiveServices::Speech;

void synthesizeSpeech()
{
// Creates an instance of a speech config with specified subscription key and service region.
// Replace with your own subscription key and service region (e.g., "westus").
auto config = SpeechConfig::FromSubscription("YourSubscriptionKey", "YourServiceRegion");

// Creates a speech synthesizer using the default speaker as audio output. The default spoken language is "en-us".
auto synthesizer = SpeechSynthesizer::FromConfig(config);

// Receive a text from console input and synthesize it to speaker.
cout << "Type some text that you want to speak..." << std::endl;
cout << "> ";
std::string text;
getline(cin, text);

auto result = synthesizer->SpeakTextAsync(text).get();

// Checks result.
if (result->Reason == ResultReason::SynthesizingAudioCompleted)
{
cout << "Speech synthesized to speaker for text [" << text << "]" << std::endl;
}
else if (result->Reason == ResultReason::Canceled)
{
auto cancellation = SpeechSynthesisCancellationDetails::FromResult(result);
cout << "CANCELED: Reason=" << (int)cancellation->Reason << std::endl;

if (cancellation->Reason == CancellationReason::Error)
{
cout << "CANCELED: ErrorCode=" << (int)cancellation->ErrorCode << std::endl;
cout << "CANCELED: ErrorDetails=[" << cancellation->ErrorDetails << "]" << std::endl;
cout << "CANCELED: Did you update the subscription info?" << std::endl;
}
}

// This is to give some time for the speaker to finish playing back the audio
cout << "Press enter to exit..." << std::endl;
cin.get();
}

int main(int argc, char **argv) {
setlocale(LC_ALL, "");
synthesizeSpeech();
return 0;
}
// </code>
Loading

0 comments on commit 5436972

Please sign in to comment.