Skip to content

Commit

Permalink
fix(SpeechToTextV1): Add configureSession parameter to RecognizeMicro…
Browse files Browse the repository at this point in the history
…phone.
  • Loading branch information
Mike Kistler committed Jun 21, 2019
1 parent 2f9e0dd commit 87f5aed
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Source/SpeechToTextV1/SpeechToText+Recognize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ extension SpeechToText {
By default, no customer ID is associated with the data.
- parameter compress: Should microphone audio be compressed to Opus format?
(Opus compression reduces latency and bandwidth.)
- parameter configureSession: A Boolean value that specifies whether to configure the AVAudioSession.
When `true`, the AVAudioSession is set to a standard configuration for microphone input. When `false`,
the current AVAudioSession configuration is used. To use an AVAudioSession configuration other than
the standard microphone configuration, set the configuration in your application and specify `false`
for the **configureSession** parameter. Default is `true`.
- parameter headers: A dictionary of request headers to be sent with this request.
- parameter completionHandler: A function executed when the request completes with a successful result or error
*/
Expand All @@ -152,13 +157,16 @@ extension SpeechToText {
learningOptOut: Bool? = nil,
customerID: String? = nil,
compress: Bool = true,
configureSession: Bool = true,
headers: [String: String]? = nil,
callback: RecognizeCallback)
{
// make sure the AVAudioSession shared instance is properly configured
do {
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: .default, options: [.defaultToSpeaker, .mixWithOthers])
if configureSession {
try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: .default, options: [.defaultToSpeaker, .mixWithOthers])
}
try audioSession.setActive(true)
} catch {
let failureReason = "Failed to setup the AVAudioSession sharedInstance properly."
Expand Down

0 comments on commit 87f5aed

Please sign in to comment.