-
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.
Samples updates for the 1.8.0 release. (#429)
- Loading branch information
1 parent
6805d96
commit 5436972
Showing
712 changed files
with
21,023 additions
and
146 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,5 @@ proguard-rules.pro text | |
*.mp3 binary | ||
*.pfx binary | ||
*.png binary | ||
*.table binary | ||
*.wav binary |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,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) | ||
|
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,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) |
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. 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> |
Oops, something went wrong.