Skip to content

Commit a3d6e1a

Browse files
authored
Fix getting microphone permission for HarmonyOS VAD+ASR example (#1582)
1 parent c9d3b6c commit a3d6e1a

File tree

1 file changed

+7
-1
lines changed
  • harmony-os/SherpaOnnxVadAsr/entry/src/main/ets/pages

1 file changed

+7
-1
lines changed

harmony-os/SherpaOnnxVadAsr/entry/src/main/ets/pages/Index.ets

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ struct Index {
4646
const permissions: Permissions[] = ["ohos.permission.MICROPHONE"];
4747
let allowed: boolean = await allAllowed(permissions);
4848
if (!allowed) {
49-
requestPermissions(permissions);
5049
console.log("request to access the microphone");
50+
const status: boolean = await requestPermissions(permissions);
51+
52+
if (!status) {
53+
console.error('access to microphone is denied')
54+
this.resultForMic = "Failed to get microphone permission. Please retry";
55+
return;
56+
}
5157

5258
allowed = await allAllowed(permissions);
5359
if (!allowed) {

0 commit comments

Comments
 (0)