Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1895 from borigas/TextToSpeechCancelHang
Browse files Browse the repository at this point in the history
Fixes hang waiting for cancelled TextToSpeech
  • Loading branch information
jfversluis committed Jan 18, 2022
2 parents 20d627e + 8b83bf9 commit 2627bf2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Xamarin.Essentials/TextToSpeech/TextToSpeech.android.cs
Expand Up @@ -109,6 +109,8 @@ public async Task SpeakAsync(string text, int max, SpeechOptions options, Cancel
if (tcsUtterances?.Task != null)
await tcsUtterances.Task;

tcsUtterances = new TaskCompletionSource<bool>();

if (cancelToken != null)
{
cancelToken.Register(() =>
Expand Down Expand Up @@ -150,7 +152,6 @@ public async Task SpeakAsync(string text, int max, SpeechOptions options, Cancel
var parts = text.SplitSpeak(max);

numExpectedUtterances = parts.Count;
tcsUtterances = new TaskCompletionSource<bool>();

var guid = Guid.NewGuid().ToString();

Expand Down

0 comments on commit 2627bf2

Please sign in to comment.