Skip to content

Commit 4b1c8d1

Browse files
authored
dispose task result to fix hanging on Windows (#24)
see Azure-Samples/cognitive-services-speech-sdk#454
1 parent 0697b16 commit 4b1c8d1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

SayIt/Program.fs

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ let getVoiceId (voice: VoiceType) =
1515

1616
let handleSynthesisResult (task: Task<SpeechSynthesisResult>) =
1717
task.Wait()
18-
match task.Result.Reason with
18+
use result = task.Result
19+
match result.Reason with
1920
| ResultReason.Canceled ->
20-
let cancellation = SpeechSynthesisCancellationDetails.FromResult task.Result
21+
let cancellation = SpeechSynthesisCancellationDetails.FromResult result
2122
if CancellationReason.Error = cancellation.Reason then
2223
match cancellation.ErrorCode with
2324
| CancellationErrorCode.ConnectionFailure ->
@@ -27,7 +28,8 @@ let handleSynthesisResult (task: Task<SpeechSynthesisResult>) =
2728
| _ ->
2829
printfn "Error: ErrorCode=%A\nErrorDetails=%A" cancellation.ErrorCode cancellation.ErrorDetails
2930
1
30-
| _ -> 0
31+
| _ ->
32+
0
3133

3234
let performSpeechSynthesis(config: Argu.ParseResults<Args>, speechConfig: SpeechConfig) =
3335
if config.Contains Output then

0 commit comments

Comments
 (0)