This repository was archived by the owner on Apr 29, 2024. It is now read-only.
File tree 3 files changed +41
-0
lines changed
WebServices/CognitiveSpeechService/CognitiveSpeechService/CognitiveSpeechService.iOS
3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 62
62
<ItemGroup >
63
63
<Compile Include =" Main.cs" />
64
64
<Compile Include =" AppDelegate.cs" />
65
+ <Compile Include =" Services\iOSMicrophoneService.cs" />
65
66
<None Include =" Entitlements.plist" />
66
67
<None Include =" Info.plist" />
67
68
<Compile Include =" Properties\AssemblyInfo.cs" />
120
121
<Reference Include =" System.Numerics.Vectors" />
121
122
</ItemGroup >
122
123
<ItemGroup >
124
+ <PackageReference Include =" Microsoft.CognitiveServices.Speech" >
125
+ <Version >1.8.0</Version >
126
+ </PackageReference >
123
127
<PackageReference Include =" Xamarin.Forms" Version =" 4.2.0.709249" />
124
128
<PackageReference Include =" Xamarin.Essentials" Version =" 1.2.0" />
125
129
</ItemGroup >
Original file line number Diff line number Diff line change 34
34
<string >CognitiveSpeechService </string >
35
35
<key >XSAppIconAssets </key >
36
36
<string >Assets.xcassets/AppIcon.appiconset </string >
37
+ <key >NSMicrophoneUsageDescription </key >
38
+ <string >Voice transcription requires microphone access </string >
37
39
</dict >
38
40
</plist >
Original file line number Diff line number Diff line change
1
+ using System . Threading . Tasks ;
2
+ using AVFoundation ;
3
+ using CognitiveSpeechService . iOS . Services ;
4
+ using CognitiveSpeechService . Services ;
5
+ using Xamarin . Forms ;
6
+
7
+ [ assembly: Dependency ( typeof ( iOSMicrophoneService ) ) ]
8
+ namespace CognitiveSpeechService . iOS . Services
9
+ {
10
+ public class iOSMicrophoneService : IMicrophoneService
11
+ {
12
+ TaskCompletionSource < bool > tcsPermissions ;
13
+
14
+ public Task < bool > GetPermissionAsync ( )
15
+ {
16
+ tcsPermissions = new TaskCompletionSource < bool > ( ) ;
17
+ RequestMicPermission ( ) ;
18
+ return tcsPermissions . Task ;
19
+ }
20
+
21
+ public void OnRequestPermissionResult ( bool isGranted )
22
+ {
23
+ tcsPermissions . TrySetResult ( isGranted ) ;
24
+ }
25
+
26
+ void RequestMicPermission ( )
27
+ {
28
+ var session = AVAudioSession . SharedInstance ( ) ;
29
+ session . RequestRecordPermission ( ( granted ) =>
30
+ {
31
+ tcsPermissions . TrySetResult ( granted ) ;
32
+ } ) ;
33
+ }
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments