Skip to content

Commit

Permalink
feat: attempted fix of sampleRate #109
Browse files Browse the repository at this point in the history
  • Loading branch information
sowens-csd committed May 3, 2021
1 parent 38ca3f3 commit faf2136
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion speech_to_text/ios/Classes/SwiftSpeechToTextPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,12 @@ public class SwiftSpeechToTextPlugin: NSObject, FlutterPlugin {
default:
break
}

self.currentTask = self.recognizer?.recognitionTask(with: currentRequest, delegate: self )
let recordingFormat = inputNode?.outputFormat(forBus: self.busForNodeTap)
let fmt = AVAudioFormat(commonFormat: recordingFormat!.commonFormat, sampleRate: theSampleRate, channels: recordingFormat!.channelCount, interleaved: recordingFormat!.isInterleaved)
try trap {
self.inputNode?.installTap(onBus: self.busForNodeTap, bufferSize: self.speechBufferSize, format: recordingFormat) { (buffer: AVAudioPCMBuffer, when: AVAudioTime) in
self.inputNode?.installTap(onBus: self.busForNodeTap, bufferSize: self.speechBufferSize, format: fmt) { (buffer: AVAudioPCMBuffer, when: AVAudioTime) in
currentRequest.append(buffer)
self.updateSoundLevel( buffer: buffer )
}
Expand Down

0 comments on commit faf2136

Please sign in to comment.