Skip to content

Commit bf5fc27

Browse files
authored
Merge pull request #207635 from eric-urban/eur/java-qs
consistent java setup and get started
2 parents e26c0c5 + 09dbf09 commit bf5fc27

File tree

7 files changed

+112
-25
lines changed

7 files changed

+112
-25
lines changed

articles/cognitive-services/Speech-Service/includes/quickstarts/captioning/cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ Follow these steps to create a new console application and install the Speech SD
4242
- On a 32-bit Windows installation, set **Active solution platform** to `x86`.
4343
1. Open **Project** > **Properties** > **Debugging**. Enter your preferred command line arguments at **Command Arguments**. See [usage and arguments](#usage-and-arguments) for the available options. Here is an example:
4444
```
45-
--key YourSubscriptionKey --region YourServiceRegion --input c:\caption\caption.this.mp4 --format any --output c:\caption\caption.output.txt - --srt --recognizing --threshold 5 --profanity mask --phrases "Contoso;Jessie;Rehaan"
45+
--key YourSubscriptionKey --region YourServiceRegion --input caption.this.mp4 --format any --output caption.output.txt - --srt --recognizing --threshold 5 --profanity mask --phrases "Contoso;Jessie;Rehaan"
4646
```
4747
Replace `YourSubscriptionKey` with your Speech resource key, and replace `YourServiceRegion` with your Speech resource [region](~/articles/cognitive-services/speech-service/regions.md), such as `westus` or `northeurope`. Make sure that the paths specified by `--input` and `--output` are valid. Otherwise you must change the paths.
4848
4949
> [!IMPORTANT]
5050
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../../../key-vault/general/overview.md). See the Cognitive Services [security](../../../../cognitive-services-security.md) article for more information.
5151
52-
1. [Build and run](/cpp/build/vscpp-step-2-build) the console application. The output file with complete captions is written to `c:\caption\caption.output.txt`. Intermediate results are shown in the console:
52+
1. [Build and run](/cpp/build/vscpp-step-2-build) the console application. The output file with complete captions is written to `caption.output.txt`. Intermediate results are shown in the console:
5353
```console
5454
00:00:00,180 --> 00:00:01,600
5555
Welcome to

articles/cognitive-services/Speech-Service/includes/quickstarts/captioning/csharp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ Follow these steps to create a new console application and install the Speech SD
4444
```
4545
1. Run the application with your preferred command line arguments. See [usage and arguments](#usage-and-arguments) for the available options. Here is an example:
4646
```dotnetcli
47-
dotnet run --key YourSubscriptionKey --region YourServiceRegion --input c:\caption\caption.this.mp4 --format any --output c:\caption\caption.output.txt - --srt --recognizing --threshold 5 --profanity mask --phrases "Contoso;Jessie;Rehaan"
47+
dotnet run --key YourSubscriptionKey --region YourServiceRegion --input caption.this.mp4 --format any --output caption.output.txt - --srt --recognizing --threshold 5 --profanity mask --phrases "Contoso;Jessie;Rehaan"
4848
```
4949
Replace `YourSubscriptionKey` with your Speech resource key, and replace `YourServiceRegion` with your Speech resource [region](~/articles/cognitive-services/speech-service/regions.md), such as `westus` or `northeurope`. Make sure that the paths specified by `--input` and `--output` are valid. Otherwise you must change the paths.
5050
5151
> [!IMPORTANT]
5252
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../../../key-vault/general/overview.md). See the Cognitive Services [security](../../../../cognitive-services-security.md) article for more information.
5353
54-
The output file with complete captions is written to `c:\caption\caption.output.txt`. Intermediate results are shown in the console:
54+
The output file with complete captions is written to `caption.output.txt`. Intermediate results are shown in the console:
5555
```console
5656
00:00:00,180 --> 00:00:01,600
5757
Welcome to

articles/cognitive-services/Speech-Service/includes/quickstarts/captioning/java.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ Follow these steps to create a new console application and install the Speech SD
7878
```
7979
1. Run the application with your preferred command line arguments. See [usage and arguments](#usage-and-arguments) for the available options. Here is an example:
8080
```console
81-
java -cp ".;target\dependency\*" Captioning --key YourSubscriptionKey --region YourServiceRegion --input c:\caption\caption.this.mp4 --format any --output c:\caption\caption.output.txt - --srt --recognizing --threshold 5 --profanity mask --phrases "Contoso;Jessie;Rehaan"
81+
java -cp ".;target\dependency\*" Captioning --key YourSubscriptionKey --region YourServiceRegion --input caption.this.mp4 --format any --output caption.output.txt - --srt --recognizing --threshold 5 --profanity mask --phrases "Contoso;Jessie;Rehaan"
8282
```
8383
Replace `YourSubscriptionKey` with your Speech resource key, and replace `YourServiceRegion` with your Speech resource [region](~/articles/cognitive-services/speech-service/regions.md), such as `westus` or `northeurope`. Make sure that the paths specified by `--input` and `--output` are valid. Otherwise you must change the paths.
8484

8585
> [!IMPORTANT]
8686
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../../../key-vault/general/overview.md). See the Cognitive Services [security](../../../../cognitive-services-security.md) article for more information.
8787

88-
The output file with complete captions is written to `c:\caption\caption.output.txt`. Intermediate results are shown in the console:
88+
The output file with complete captions is written to `caption.output.txt`. Intermediate results are shown in the console:
8989
```console
9090
00:00:00,180 --> 00:00:01,600
9191
Welcome to

articles/cognitive-services/Speech-Service/includes/quickstarts/captioning/javascript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Follow these steps to create a Node.js console application and install the Speec
3636
```
3737
1. Run the application with your preferred command line arguments. See [usage and arguments](#usage-and-arguments) for the available options. Here is an example:
3838
```console
39-
node captioning.js --key YourSubscriptionKey --region YourServiceRegion --input c:\caption\caption.this.wav --output c:\caption\caption.output.txt - --srt --recognizing --threshold 5 --profanity mask --phrases "Contoso;Jessie;Rehaan"
39+
node captioning.js --key YourSubscriptionKey --region YourServiceRegion --input caption.this.wav --output caption.output.txt - --srt --recognizing --threshold 5 --profanity mask --phrases "Contoso;Jessie;Rehaan"
4040
```
4141
Replace `YourSubscriptionKey` with your Speech resource key, and replace `YourServiceRegion` with your Speech resource [region](~/articles/cognitive-services/speech-service/regions.md), such as `westus` or `northeurope`. Make sure that the paths specified by `--input` and `--output` are valid. Otherwise you must change the paths.
4242

@@ -46,7 +46,7 @@ Follow these steps to create a Node.js console application and install the Speec
4646
> [!IMPORTANT]
4747
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../../../key-vault/general/overview.md). See the Cognitive Services [security](../../../../cognitive-services-security.md) article for more information.
4848

49-
The output file with complete captions is written to `c:\caption\caption.output.txt`. Intermediate results are shown in the console:
49+
The output file with complete captions is written to `caption.output.txt`. Intermediate results are shown in the console:
5050
```console
5151
00:00:00,180 --> 00:00:01,600
5252
Welcome to

articles/cognitive-services/Speech-Service/includes/quickstarts/speech-to-text-basics/java.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,53 @@ ms.author: eur
1818

1919
Before you can do anything, you need to install the Speech SDK. The sample in this quickstart works with the [Java Runtime](~/articles/cognitive-services/speech-service/quickstarts/setup-platform.md?pivots=programming-language-java&tabs=jre).
2020

21+
1. Install [Apache Maven](https://maven.apache.org/install.html)
22+
1. Create a new `pom.xml` file in the root of your project, and copy the following into it:
23+
```xml
24+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
25+
<modelVersion>4.0.0</modelVersion>
26+
<groupId>com.microsoft.cognitiveservices.speech.samples</groupId>
27+
<artifactId>quickstart-eclipse</artifactId>
28+
<version>1.0.0-SNAPSHOT</version>
29+
<build>
30+
<sourceDirectory>src</sourceDirectory>
31+
<plugins>
32+
<plugin>
33+
<artifactId>maven-compiler-plugin</artifactId>
34+
<version>3.7.0</version>
35+
<configuration>
36+
<source>1.8</source>
37+
<target>1.8</target>
38+
</configuration>
39+
</plugin>
40+
</plugins>
41+
</build>
42+
<repositories>
43+
<repository>
44+
<id>maven-cognitiveservices-speech</id>
45+
<name>Microsoft Cognitive Services Speech Maven Repository</name>
46+
<url>https://azureai.azureedge.net/maven/</url>
47+
</repository>
48+
</repositories>
49+
<dependencies>
50+
<dependency>
51+
<groupId>com.microsoft.cognitiveservices.speech</groupId>
52+
<artifactId>client-sdk</artifactId>
53+
<version>1.23.0</version>
54+
</dependency>
55+
</dependencies>
56+
</project>
57+
```
58+
1. Install the Speech SDK and dependencies.
59+
```console
60+
mvn clean dependency:copy-dependencies
61+
```
62+
2163
## Recognize speech from a microphone
2264

2365
Follow these steps to create a new console application for speech recognition.
2466

25-
1. Open a command prompt where you want the new project, and create a new file named `SpeechRecognition.java`.
67+
1. Create a new file named `SpeechRecognition.java` in the same project root directory.
2668
1. Copy the following code into `SpeechRecognition.java`:
2769

2870
```java
@@ -82,7 +124,8 @@ Follow these steps to create a new console application for speech recognition.
82124
Run your new console application to start speech recognition from a microphone:
83125

84126
```console
85-
java SpeechRecognition
127+
javac SpeechRecognition.java -cp ".;target\dependency\*"
128+
java -cp ".;target\dependency\*" SpeechRecognition
86129
```
87130

88131
Speak into your microphone when prompted. What you speak should be output as text:

articles/cognitive-services/Speech-Service/includes/quickstarts/speech-translation-basics/java.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@ ms.author: eur
1717
> [!div class="nextstepaction"]
1818
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVA&Pillar=Speech&Product=Speech-translation&Page=quickstart&Section=Prerequisites" target="_target">I ran into an issue</a>
1919
20+
2021
## Set up the environment
2122

2223
Before you can do anything, you need to install the Speech SDK. The sample in this quickstart works with the [Java Runtime](~/articles/cognitive-services/speech-service/quickstarts/setup-platform.md?pivots=programming-language-java&tabs=jre).
2324

24-
To complete the steps in this quickstart, you must also install [Apache Maven](https://maven.apache.org/install.html).
25-
26-
> [!div class="nextstepaction"]
27-
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVA&Pillar=Speech&Product=Speech-translation&Page=quickstart&Section=Set-up-the-environment" target="_target">I ran into an issue</a>
28-
29-
## Translate speech from a microphone
30-
To complete the steps in this quickstart, you must also install [Apache Maven](https://maven.apache.org/install.html).
31-
Follow these steps to create a new console application for speech recognition.
32-
33-
1. Open a command prompt where you want the new project, and create a new `pom.xml` file.
34-
1. Copy the following XML content into `pom.xml`:
25+
1. Install [Apache Maven](https://maven.apache.org/install.html)
26+
1. Create a new `pom.xml` file in the root of your project, and copy the following into it:
3527
```xml
3628
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3729
<modelVersion>4.0.0</modelVersion>
@@ -67,10 +59,18 @@ Follow these steps to create a new console application for speech recognition.
6759
</dependencies>
6860
</project>
6961
```
70-
1. Run the following Maven command to install the Speech SDK and dependencies.
62+
1. Install the Speech SDK and dependencies.
7163
```console
7264
mvn clean dependency:copy-dependencies
7365
```
66+
67+
> [!div class="nextstepaction"]
68+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVA&Pillar=Speech&Product=Speech-translation&Page=quickstart&Section=Set-up-the-environment" target="_target">I ran into an issue</a>
69+
70+
## Translate speech from a microphone
71+
72+
Follow these steps to create a new console application for speech recognition.
73+
7474
1. Create a new file named `SpeechTranslation.java` in the same project root directory.
7575
1. Copy the following code into `SpeechTranslation.java`:
7676

articles/cognitive-services/Speech-Service/includes/quickstarts/text-to-speech-basics/java.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,59 @@ ms.author: eur
1414

1515
[!INCLUDE [Prerequisites](../../common/azure-prerequisites.md)]
1616

17+
1718
## Set up the environment
1819

1920
Before you can do anything, you need to install the Speech SDK. The sample in this quickstart works with the [Java Runtime](~/articles/cognitive-services/speech-service/quickstarts/setup-platform.md?pivots=programming-language-java&tabs=jre).
2021

22+
1. Install [Apache Maven](https://maven.apache.org/install.html)
23+
1. Create a new `pom.xml` file in the root of your project, and copy the following into it:
24+
```xml
25+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
26+
<modelVersion>4.0.0</modelVersion>
27+
<groupId>com.microsoft.cognitiveservices.speech.samples</groupId>
28+
<artifactId>quickstart-eclipse</artifactId>
29+
<version>1.0.0-SNAPSHOT</version>
30+
<build>
31+
<sourceDirectory>src</sourceDirectory>
32+
<plugins>
33+
<plugin>
34+
<artifactId>maven-compiler-plugin</artifactId>
35+
<version>3.7.0</version>
36+
<configuration>
37+
<source>1.8</source>
38+
<target>1.8</target>
39+
</configuration>
40+
</plugin>
41+
</plugins>
42+
</build>
43+
<repositories>
44+
<repository>
45+
<id>maven-cognitiveservices-speech</id>
46+
<name>Microsoft Cognitive Services Speech Maven Repository</name>
47+
<url>https://azureai.azureedge.net/maven/</url>
48+
</repository>
49+
</repositories>
50+
<dependencies>
51+
<dependency>
52+
<groupId>com.microsoft.cognitiveservices.speech</groupId>
53+
<artifactId>client-sdk</artifactId>
54+
<version>1.23.0</version>
55+
</dependency>
56+
</dependencies>
57+
</project>
58+
```
59+
1. Install the Speech SDK and dependencies.
60+
```console
61+
mvn clean dependency:copy-dependencies
62+
```
63+
2164
## Synthesize to speaker output
2265

2366
Follow these steps to create a new console application for speech recognition.
2467

25-
1. Open a command prompt where you want the new project, and create a new file named `SpeechSynthesis.java`.
26-
1. Copy the following code into `SpeechSynthesis.java`:
68+
1. Create a new file named `SpeechSynthesis.java` in the same project root directory.
69+
1. Copy the following code into `SpeechSynthesis.java`:
2770

2871
```java
2972
import com.microsoft.cognitiveservices.speech.*;
@@ -81,7 +124,8 @@ Follow these steps to create a new console application for speech recognition.
81124
Run your new console application to start speech synthesis to the default speaker.
82125

83126
```console
84-
java SpeechSynthesis
127+
javac SpeechSynthesis.java -cp ".;target\dependency\*"
128+
java -cp ".;target\dependency\*" SpeechSynthesis
85129
```
86130

87131
Enter some text that you want to speak. For example, type "I'm excited to try text to speech." Press the Enter key to hear the synthesized speech.

0 commit comments

Comments
 (0)