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

Fix iOS microphone crash #2141

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions samples/swift/ios/speech-samples/speech-samples/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMicrophoneUsageDescription</key>
<string>For microphone input testing</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down Expand Up @@ -62,5 +64,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import UIKit
import MicrosoftCognitiveServicesSpeech
import Differ
import AVFoundation

extension StringProtocol {
var words: [SubSequence] {
Expand Down Expand Up @@ -84,8 +85,14 @@ class ViewController: UIViewController {
}

@objc func pronunciationAssessmentWithMicrophoneButtonClicked(){
DispatchQueue.global(qos: .userInitiated).async {
self.pronunciationAssessmentWithMicrophone()
AVAudioSession.sharedInstance().requestRecordPermission { granted in
if granted {
DispatchQueue.global(qos: .userInitiated).async {
self.pronunciationAssessmentWithMicrophone()
}
} else {
print("Microphone is not permitted!")
}
}
}

Expand Down