Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] SpeechRecognizer.prototype.recognizeOnceAsync could return a Promise #547

Open
fungiboletus opened this issue Jul 5, 2022 · 6 comments
Assignees
Labels
in review Acknowledged and being looked at now

Comments

@fungiboletus
Copy link

fungiboletus commented Jul 5, 2022

Hei,

This is not very important, but you may want some user feedback to justify the implementation. It would be nice if SpeechRecognizer.prototype.recognizeOnceAsync could return a promise in addition to taking callbacks in its arguments. It would not break backward compatibility and improve the user experience IMHO.

From:

const result = await new Promise<SpeechSDKType.SpeechRecognitionResult>((resolve, reject) => {
    recognizer.recognizeOnceAsync(resolve, reject);
});

To:

const result = await recognizer.recognizeOnceAsync();
@jhakulin
Copy link
Member

jhakulin commented Jul 6, 2022

@fungiboletus Thanks for the great feedback! I created internal workitem ref. 4356980 for the issue.

@Mike-Bell
Copy link

I think there's a handful of similar places around the SDK. For instance, I also wish that SpeechSynthesizer.speakTextAsync was a promise.

@rhurey
Copy link
Member

rhurey commented Jul 7, 2022

@fungiboletus maybe there's something here I don't know, but how would changing from taking callbacks to returning a promise not be a breaking change?

@Mike-Bell
Copy link

maybe there's something here I don't know, but how would changing from taking callbacks to returning a promise not be a breaking change?

I've seen a lot of API's that support both on the same function: the function returns a promise that can be awaited, and it additionally allows you to supply an optional callback that will be called if supplied.

@rhurey
Copy link
Member

rhurey commented Jul 8, 2022

Well, that'll be my "Why didn't I think of that?" for the week.

Thanks!

@fungiboletus
Copy link
Author

Sorry I didn't formulate well, I edited the issue. I think you can keep the callbacks for backward compatibility and return a promise too. It's not returning anything in the current version.

@jhakulin jhakulin added the in review Acknowledged and being looked at now label Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review Acknowledged and being looked at now
Projects
None yet
Development

No branches or pull requests

4 participants