Skip to content

[BUG] iOS and Android ListenAsync's Progress do not behave consistently #1723

Description

@vchelaru

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

iOS and Android's ListenAsync's recognitionResult callback do not behave consistently.

The SpeechToText documentation can be found here: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/essentials/speech-to-text?tabs=android

This document suggests that the argument to the recognitionResult (Progress) callback provides the new text that was spoken since the last callback:

    var recognitionResult = await speechToText.ListenAsync(
                                        CultureInfo.GetCultureInfo(Language),
                                        new Progress<string>(partialText =>
                                        {
                                            RecognitionText += partialText + " ";
                                        }), cancellationToken);

Our tests indicate that the callback includes the fully spoken phrase on Android but only the new words/phrase on iOS.

Expected Behavior

All platforms should behave consistently. If the docs are to be followed, then the callback should always include only the new word/phrases, rather than the entire phrase.

Steps To Reproduce

  1. Create a .NET project
  2. Add the code as shown below
  3. Run on iOS
  4. Speak
  5. Observe the output
  6. Run on Android
  7. Speak
  8. Observe the output
await SpeechToText.Default.ListenAsync(
    CultureInfo.CurrentCulture,
    new Progress(partialText =>
    {
        System.Diagnostics.Debug.WriteLine(partialText);
    }), token);

iOS Output:

[0:] This
[0:] is
[0:] the
[0:] test

Android Output:

[0:] 
[0:] 
[0:] 
[0:] this
[0:] this is
[0:] this is a

Link to public reproduction project repository

Unfortunately I do not have this, reproduced at work and do not have time to make one :(

Environment

- .NET MAUI CommunityToolkit:7.0.1
- OS: iOS 17.3 and Android 10.0
- .NET MAUI: 8.0.7

Anything else?

We are going to be updating our app to handle this method differently on iOS and Android. Fixing this could result in a breaking change for users, but I think it's worth doing to keep it consistent going forward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions