Skip to content

Instantly share code, notes, and snippets.

@FedeRotoli
Created March 31, 2020 13:46
Show Gist options
  • Save FedeRotoli/e5b9e70c57b34acc23705a785ebc92d8 to your computer and use it in GitHub Desktop.
Save FedeRotoli/e5b9e70c57b34acc23705a785ebc92d8 to your computer and use it in GitHub Desktop.
import UIKit
import SoundAnalysis
class SoundAnalyzerController: UIViewController {
private let audioEngine = AVAudioEngine()
private var soundClassifier = EmotionModel()
var inputFormat: AVAudioFormat!
var analyzer: SNAudioStreamAnalyzer!
var resultsObserver = ResultsObserver()
let analysisQueue = DispatchQueue(label: "com.apple.AnalysisQueue")
@IBOutlet weak var transcriberText: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
resultsObserver.delegate = self
inputFormat = audioEngine.inputNode.inputFormat(forBus: 0)
analyzer = SNAudioStreamAnalyzer(format: inputFormat)
}
override func viewDidAppear(_ animated: Bool) {
startAudioEngine()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment