         socket?.writeData(audioData)
     }
 
-    private func createMicrophoneInput() -> AVCaptureDeviceInput? {
+    /**
+     Create a microphone input for use with an `AVCaptureSession`.
+     
+     - returns: An `AVCaptureDeviceInput` for the default audio input device, or nil if the
+        default audio input device is inaccessible.
+     */
+    func createMicrophoneInput() -> AVCaptureDeviceInput? {
         let microphoneDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)
         guard let microphoneInput = try? AVCaptureDeviceInput(device: microphoneDevice) else {
-            if let failure = failure {
-                let description = "Unable to access the microphone."
-                let error = createError(SpeechToTextConstants.domain, description: description)
-                failure(error)
-            }
+            let description = "Unable to access the microphone."
+            let error = createError(SpeechToTextConstants.domain, description: description)
+            failure?(error)
             return nil
         }
         return microphoneInput
     }
 
+    /**
+     Create a transcription output for use with an `AVCaptureSession`.
+
+     - returns: An `AVCaptureAudioDataOutput` that streams audio data to Speech to Text.
+     */
     func createTranscriptionOutput() -> AVCaptureAudioDataOutput {
         let output = AVCaptureAudioDataOutput()
         let queue = dispatch_queue_create("stt_streaming", DISPATCH_QUEUE_SERIAL)
         output.setSampleBufferDelegate(self, queue: queue)
         return output
     }
-}+}

    private var socket: SpeechToTextWebSocket?
    private var captureSession: AVCaptureSession?

    init?(
        authStrategy: AuthenticationStrategy,
        settings: SpeechToTextSettings,

        self.socket = socket
    }

    /**
     Start streaming microphone audio to Speech to Text.

     - returns: `true` if the `AVCaptureSession` could be configured to stream microphone audio
        to the Speech to Text service; false, otherwise.
     */
    func startStreaming() -> Bool {

        settings.contentType = .L16(rate: 44100, channels: 1)
