From a3d6e1acc7e65d2bc9eda56d5548eeff295e9349 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Sat, 30 Nov 2024 16:24:22 +0800 Subject: [PATCH] Fix getting microphone permission for HarmonyOS VAD+ASR example (#1582) --- .../SherpaOnnxVadAsr/entry/src/main/ets/pages/Index.ets | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/harmony-os/SherpaOnnxVadAsr/entry/src/main/ets/pages/Index.ets b/harmony-os/SherpaOnnxVadAsr/entry/src/main/ets/pages/Index.ets index 5aef4d9a8..b0695f3a0 100644 --- a/harmony-os/SherpaOnnxVadAsr/entry/src/main/ets/pages/Index.ets +++ b/harmony-os/SherpaOnnxVadAsr/entry/src/main/ets/pages/Index.ets @@ -46,8 +46,14 @@ struct Index { const permissions: Permissions[] = ["ohos.permission.MICROPHONE"]; let allowed: boolean = await allAllowed(permissions); if (!allowed) { - requestPermissions(permissions); console.log("request to access the microphone"); + const status: boolean = await requestPermissions(permissions); + + if (!status) { + console.error('access to microphone is denied') + this.resultForMic = "Failed to get microphone permission. Please retry"; + return; + } allowed = await allAllowed(permissions); if (!allowed) {