Skip to content

Commit

Permalink
Merge branch 'minhbn00-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlutton committed Nov 11, 2024
2 parents 9398803 + c196b10 commit 967a138
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ios/Classes/SwiftFlutterTtsPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ public class SwiftFlutterTtsPlugin: NSObject, FlutterPlugin, AVSpeechSynthesizer
if output == nil {
do {
if #available(iOS 17.0, *) {
guard let audioFormat = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: Double(22050), channels: 1, interleaved: false) else {
guard let audioFormat = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: pcmBuffer.format.sampleRate, channels: 1, interleaved: false) else {
NSLog("Error creating audio format for iOS 17+")
failed = true
return
}
output = try AVAudioFile(forWriting: fileURL, settings: audioFormat.settings)
} else {
output = try AVAudioFile(forWriting: fileURL, settings: pcmBuffer.format.settings, commonFormat: .pcmFormatInt16, interleaved: false)
output = try AVAudioFile(forWriting: fileURL, settings: pcmBuffer.format.settings, commonFormat: .pcmFormatFloat32, interleaved: false)
}
} catch {
NSLog("Error creating AVAudioFile: \(error.localizedDescription)")
Expand Down

0 comments on commit 967a138

Please sign in to comment.