@@ -24,6 +24,12 @@ <h1 style="font-weight:500;">Speech Recognition Speech SDK not found (microsoft.
24
24
< td align ="right "> Region</ td >
25
25
< td > < input id ="serviceRegion " type ="text " size ="40 " value ="YourServiceRegion "> </ td >
26
26
</ tr >
27
+ < tr >
28
+ < td align ="right "> File to Recognize</ td >
29
+ < td >
30
+ < input type ="file " id ="filePicker " accept =".wav " />
31
+ </ td >
32
+ </ tr >
27
33
< tr >
28
34
< td > </ td >
29
35
< td > < button id ="startRecognizeOnceAsyncButton "> Start recognition</ button > </ td >
@@ -65,6 +71,7 @@ <h1 style="font-weight:500;">Speech Recognition Speech SDK not found (microsoft.
65
71
// status fields and start button in UI
66
72
var phraseDiv ;
67
73
var startRecognizeOnceAsyncButton ;
74
+ var filePicker , audioFile ;
68
75
69
76
// subscription key and region for speech services.
70
77
var subscriptionKey , serviceRegion ;
@@ -77,6 +84,11 @@ <h1 style="font-weight:500;">Speech Recognition Speech SDK not found (microsoft.
77
84
subscriptionKey = document . getElementById ( "subscriptionKey" ) ;
78
85
serviceRegion = document . getElementById ( "serviceRegion" ) ;
79
86
phraseDiv = document . getElementById ( "phraseDiv" ) ;
87
+ filePicker = document . getElementById ( "filePicker" ) ;
88
+ filePicker . addEventListener ( "change" , function ( ) {
89
+ audioFile = filePicker . files [ 0 ] ;
90
+ startRecognizeOnceAsyncButton . disabled = false ;
91
+ } ) ;
80
92
81
93
startRecognizeOnceAsyncButton . addEventListener ( "click" , function ( ) {
82
94
startRecognizeOnceAsyncButton . disabled = true ;
@@ -95,7 +107,7 @@ <h1 style="font-weight:500;">Speech Recognition Speech SDK not found (microsoft.
95
107
}
96
108
97
109
speechConfig . speechRecognitionLanguage = "en-US" ;
98
- var audioConfig = SpeechSDK . AudioConfig . fromDefaultMicrophoneInput ( ) ;
110
+ var audioConfig = SpeechSDK . AudioConfig . fromWavFileInput ( audioFile ) ;
99
111
recognizer = new SpeechSDK . SpeechRecognizer ( speechConfig , audioConfig ) ;
100
112
101
113
recognizer . recognizeOnceAsync (
0 commit comments