Skip to content

Commit a801583

Browse files
committed
sr microphone QS, other updates
1 parent 8d1d6de commit a801583

File tree

4 files changed

+103
-21
lines changed

4 files changed

+103
-21
lines changed

articles/cognitive-services/Speech-Service/includes/quickstarts/from-microphone/go/go.md

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,93 @@ Before you get started:
2323
2424
## Support and updates
2525

26-
Updates to the Speech SDK Go package are distributed via
26+
Updates to the Speech SDK Go package are distributed via
2727

28-
### Run the sample
28+
## Setup your environment
2929

30-
You can copy the [sample code](#sample-code) from this quickstart to a source file `quickstart.go` and run it in your IDE or in the console:
30+
Update the go.mod file with the latest SDK version by adding this line
31+
```sh
32+
require (
33+
github.com/Microsoft/cognitive-services-speech-sdk-go v1.11.0-alpha1
34+
)
35+
```
36+
37+
## Start with some boilerplate code
38+
1. Replace the contents of your source file (e.g. `sr-quickstart.go`) with the below, which includes:
39+
40+
- "main" package definition
41+
- importing the necessary modules from the Speech SDK
42+
- variables for storing the ########TODO######## information that will be replaced later in this quickstart
43+
- a simple implementation using the microphone for audio input
44+
- event handlers for various events that take place during a speech recognition
3145

3246
```sh
33-
???
47+
package recognizer
48+
49+
import (
50+
"bufio"
51+
"fmt"
52+
"os"
53+
54+
"github.com/Microsoft/cognitive-services-speech-sdk-go/audio"
55+
"github.com/Microsoft/cognitive-services-speech-sdk-go/speech"
56+
)
57+
58+
func recognizingHandler(event speech.SpeechRecognitionEventArgs) {
59+
defer event.Close()
60+
fmt.Println("Recognizing:", event.Result.Text)
61+
}
62+
63+
func recognizedHandler(event speech.SpeechRecognitionEventArgs) {
64+
defer event.Close()
65+
fmt.Println("Recognized:", event.Result.Text)
66+
}
67+
68+
func cancelledHandler(event speech.SpeechRecognitionCanceledEventArgs) {
69+
defer event.Close()
70+
fmt.Println("Received a cancellation: ", event.ErrorDetails)
71+
}
72+
73+
func main() {
74+
subscription := "YOUR_SUBSCRIPTION_KEY"
75+
region := "YOUR_SUBSCRIPTIONKEY_REGION"
76+
77+
audioConfig, err := audio.NewAudioConfigFromDefaultMicrophoneInput()
78+
if err != nil {
79+
fmt.Println("Got an error: ", err)
80+
return
81+
}
82+
defer audioConfig.Close()
83+
config, err := speech.NewSpeechConfigFromSubscription(subscription, region)
84+
if err != nil {
85+
fmt.Println("Got an error: ", err)
86+
return
87+
}
88+
defer config.Close()
89+
speechRecognizer, err := speech.NewSpeechRecognizerFromConfig(config, audioConfig)
90+
if err != nil {
91+
fmt.Println("Got an error: ", err)
92+
return
93+
}
94+
defer speechRecognizer.Close()
95+
speechRecognizer.Recognizing(recognizingHandler)
96+
speechRecognizer.Recognized(recognizedHandler)
97+
speechRecognizer.Canceled(cancelledHandler)
98+
speechRecognizer.StartContinuousRecognitionAsync()
99+
defer speechRecognizer.StopContinuousRecognitionAsync()
100+
bufio.NewReader(os.Stdin).ReadBytes('\n')
101+
}
34102
```
35103
36-
Or you can download this quickstart tutorial as
104+
## Build and run
105+
You're now set up to build your project and test your custom voice assistant using the Speech service.
106+
1. Build your project, e.g. **"go build"**
107+
2. Run the module and speak a phrase or sentence into your device's microphone. Your speech is transmitted to the Speech service and transcribed to text, which appears in the output.
37108
38-
### Sample code
39109
40110
> [!NOTE]
41111
> The Speech SDK will default to recognizing using en-us for the language, see [Specify source language for speech to text](../../../../how-to-specify-source-language.md) for information on choosing the source language.
42112
43-
### Install and use the Speech SDK with Visual Studio Code
44-
45-
46113
47114
## Next steps
48115

articles/cognitive-services/Speech-Service/includes/quickstarts/voice-assistants/go/go.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,6 @@ func main() {
8181
return
8282
}
8383
defer connector.Close()
84-
sessionStartedHandler := func(event speech.SessionEventArgs) {
85-
defer event.Close()
86-
fmt.Println("Session Started")
87-
}
88-
sessionStoppedHandler := func(event speech.SessionEventArgs) {
89-
defer event.Close()
90-
fmt.Println("Session Stopped")
91-
}
92-
connector.SessionStarted(sessionStartedHandler)
93-
connector.SessionStopped(sessionStoppedHandler)
9484
activityReceivedHandler := func(event dialog.ActivityReceivedEventArgs) {
9585
defer event.Close()
9686
fmt.Println("Received an activity.")
@@ -132,7 +122,6 @@ You're now set up to build your project and test your custom voice assistant usi
132122
> [!NOTE]
133123
> The Speech SDK will default to recognizing using en-us for the language, see [Specify source language for speech to text](../../../../how-to-specify-source-language.md) for information on choosing the source language.
134124
135-
136125
## Next steps
137126
138127
[!INCLUDE [footer](./footer.md)]

articles/cognitive-services/Speech-Service/quickstarts/speech-to-text-from-microphone.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.subservice: speech-service
1010
ms.topic: quickstart
1111
ms.date: 02/10/2020
1212
ms.author: dapine
13-
zone_pivot_groups: programming-languages-set-two
13+
zone_pivot_groups: programming-languages-set-sixteen
1414
---
1515

1616
# Quickstart: Recognize speech from a microphone
@@ -55,6 +55,16 @@ zone_pivot_groups: programming-languages-set-two
5555

5656
::: zone-end
5757

58+
::: zone pivot="programming-language-go"
59+
60+
[!INCLUDE [Header](../includes/quickstarts/from-microphone/header.md)]
61+
62+
[!INCLUDE [Python Header](../includes/quickstarts/from-microphone/go/header.md)]
63+
64+
[!INCLUDE [python](../includes/quickstarts/from-microphone/go/go.md)]
65+
66+
::: zone-end
67+
5868
::: zone pivot="programming-language-more"
5969

6070
[!INCLUDE [Header](../includes/quickstarts/from-microphone/more/header.md)]

articles/zone-pivot-groups.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,21 @@ groups:
281281
title: Java
282282
- id: programming-language-go
283283
title: Go
284+
- id: programming-language-more
285+
title: More languages...
286+
- id: programming-languages-set-sixteen
287+
title: Programming languages
288+
prompt: Choose a programming language
289+
pivots:
290+
- id: programming-language-csharp
291+
title: C#
292+
- id: programming-language-cpp
293+
title: C++
294+
- id: programming-language-java
295+
title: Java
296+
- id: programming-language-python
297+
title: Python
298+
- id: programming-language-go
299+
title: Go
284300
- id: programming-language-more
285301
title: More languages...

0 commit comments

Comments
 (0)