File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
app/SharedWebComponents/Pages Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,26 @@ private void OnSendPrompt()
80
80
} ;
81
81
}
82
82
83
- SpeechSynthesis . Speak ( utterance ) ;
84
-
85
- _isReadingResponse = false ;
86
- StateHasChanged ( ) ;
83
+ try
84
+ {
85
+ SpeechSynthesis . Speak ( utterance , duration =>
86
+ {
87
+ _isReadingResponse = false ;
88
+ StateHasChanged ( ) ;
89
+ } ) ;
90
+ }
91
+ catch
92
+ {
93
+ // TODO: Find a better way to do this
94
+ // The Blazor.SpeechSynthesis.WebAssembly API supports the callback,
95
+ // however the underlying code does not do this using a DI-friendly way.
96
+ // The code assumes the concrete implementation for the ISpeechSynthesisService
97
+ // service is the concrete Web Assembly type which is not valid. However, the
98
+ // alternate API is something MAUI can implement.
99
+ SpeechSynthesis . Speak ( utterance ) ;
100
+ _isReadingResponse = false ;
101
+ StateHasChanged ( ) ;
102
+ }
87
103
}
88
104
}
89
105
You can’t perform that action at this time.
0 commit comments