This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install -U coremltools |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deactivate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python --version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install virtualenv | |
virtualenv --python=/usr/bin/python2.7 python27 | |
source python27/bin/activate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func recordButtonTapped() { | |
if (self.recognitionTask?.state == .running) { | |
self.recognitionTask?.finish() | |
self.recognitionRequest = nil | |
self.recordButton.isEnabled = false | |
} else { | |
try! startRecording() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func startRecording() throws { | |
if let recognitionTask = recognitionTask { | |
recognitionTask.cancel() | |
self.recognitionTask = nil | |
} | |
let path = Bundle.main.path(forResource: "your-file", ofType: "mp3") | |
if let path = path { | |
let url = URL(fileURLWithPath: path) | |
recognitionRequest = SFSpeechURLRecognitionRequest(url: url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var recognitionRequest: SFSpeechURLRecognitionRequest? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func recordButtonTapped() { | |
if audioEngine.isRunning { | |
audioEngine.stop() | |
recognitionRequest?.endAudio() | |
recordButton.isEnabled = false | |
} else { | |
try! startRecording() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func startRecording() throws { | |
// 1 | |
if let recognitionTask = self.recognitionTask { | |
recognitionTask.cancel() | |
self.recognitionTask = nil | |
} | |
// 2 | |
let audioSession = AVAudioSession.sharedInstance() | |
try audioSession.setCategory(AVAudioSessionCategoryRecord) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest? | |
private let audioEngine = AVAudioEngine() |