-
Notifications
You must be signed in to change notification settings - Fork 29
/
main.go
60 lines (54 loc) · 2.53 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// Package main demonstrates usages for the speech recognizer and dialog service connector
package main
import (
"fmt"
"os"
"github.com/Microsoft/cognitive-services-speech-sdk-go/samples/dialog_service_connector"
"github.com/Microsoft/cognitive-services-speech-sdk-go/samples/recognizer"
"github.com/Microsoft/cognitive-services-speech-sdk-go/samples/synthesizer"
"github.com/Microsoft/cognitive-services-speech-sdk-go/samples/speaker_recognition"
)
type functionMap = map[string]func(string, string, string)
func printHelp(executableName string, samples functionMap) {
fmt.Println("Input not valid")
fmt.Println("Usage: ")
fmt.Println(executableName, " <subscription> <region> <file> <sample>")
fmt.Println("Where sample is of the format <scenario>:<sample>")
fmt.Println("Available samples:")
for id, _ := range samples {
fmt.Println(" -- ", id)
}
}
func main() {
samples := functionMap{
"speech_recognizer:RecognizeOnceFromWavFile": recognizer.RecognizeOnceFromWavFile,
"speech_recognizer:RecognizeOnceFromCompressedFile": recognizer.RecognizeOnceFromCompressedFile,
"speech_recognizer:RecognizeOnceFromALAWFile": recognizer.RecognizeOnceFromALAWFile,
"speech_recognizer:ContinuousFromMicrophone": recognizer.ContinuousFromMicrophone,
"speech_recognizer:RecognizeContinuousUsingWrapper": recognizer.RecognizeContinuousUsingWrapper,
"dialog_service_connector:ListenOnce": dialog_service_connector.ListenOnce,
"dialog_service_connector:KWS": dialog_service_connector.KWS,
"dialog_service_connector:ListenOnceFromStream": dialog_service_connector.ListenOnceFromStream,
"speech_synthesizer:SynthesisToSpeaker": synthesizer.SynthesisToSpeaker,
"speech_synthesizer:SynthesisToAudioDataStream": synthesizer.SynthesisToAudioDataStream,
"speaker_recognizer:IndependentIdentification": speaker_recognition.IndependentIdentification,
"speaker_recognizer:IndependentVerification": speaker_recognition.IndependentVerification,
}
args := os.Args[1:]
if len(args) != 4 {
printHelp(os.Args[0], samples)
return
}
subscription := args[0]
region := args[1]
file := args[2]
sample := args[3]
sampleFunction := samples[sample]
if sampleFunction == nil {
printHelp(os.Args[0], samples)
return
}
sampleFunction(subscription, region, file)
}