A coisa mais sensacional que passou despercebida na WWDC

A coisa mais sensacional que passou despercebida na WWDC

Apresentação dada no TDC SP 2016 Trilha iOS
Cógido e Deckset: https://github.com/fpg1503/AmazingSpeechFrameworkTalk

4d9cba345c724ca98dc17a9ea8a7e0c6?s=128

Francesco

July 05, 2016
Tweet

Transcript

  1. The Developer's Conference

  2. The Developer's Conference Francesco Perrotti-Garcia

  3. A coisa mais sensacional que passou despercebida na WWDC

  4. Francesco Perrotti-Garcia iOS Developer @fpg1503

  5. None
  6. None
  7. None
  8. WWDC Schedule

  9. None
  10. Session 509

  11. Speech.framewor

  12. import Speech

  13. Siri

  14. Keyboard Dictation

  15. Normalmente online

  16. Usage description Info.plist

  17. NSSpeechRecognitionUsageDescription

  18. SFSpeechRecognize

  19. public class func requestAuthorization(_ handler: (SFSpeechRecognizerAuthorizationSta tus) -> Swift.Void)

  20. SFSpeechRecognizer.init?(locale: Locale)

  21. public enum SFSpeechRecognizerAuthorizationStatus : Int { case notDetermined case denied

    case restricted case authorized }
  22. SFSpeechURLRecognitionRequest

  23. · App de mensagem · App de músicas · Qualquer

    coisa gravada
  24. SFSpeechAudioBufferRecognitionRequest

  25. let recognitionRequest = SFSpeechAudioBufferRecognitionRequest() recognitionRequest.shouldReportPartialResults = true

  26. public func recognitionTask(with request: SFSpeechRecognitionRequest, resultHandler: (SFSpeechRecognitionResult?, NSError?) -> Swift.Void)

    -> SFSpeechRecognitionTask
  27. Live com AVAudioEngine

  28. let audioSession = AVAudioSession.sharedInstance() try audioSession.setCategory(AVAudioSessionCategoryRecord) try audioSession.setMode(AVAudioSessionModeMeasurement) try audioSession.setActive(true,

    with: .notifyOthersOnDeactivation)
  29. let audioEngine = AVAudioEngine() guard let inputNode = audioEngine.inputNode else

    { fatalError("Audio engine has no input node") }
  30. AVAudioNode

  31. public func installTap(onBus bus: AVAudioNodeBus, bufferSize: AVAudioFrameCount, format: AVAudioFormat?, block

    tapBlock: AVFoundation.AVAudioNodeTapBlock)
  32. public typealias AVAudioNodeTapBlock = (AVAudioPCMBuffer, AVAudioTime) -> Swift.Void

  33. Começar

  34. let recordingFormat = inputNode.outputFormat(forBus: 0) inputNode.installTap(onBus: 0, bufferSize: 1024, format:

    recordingFormat) { self.recognitionRequest?.append($0.0) } audioEngine.prepare() try audioEngine.start()
  35. Terminar

  36. audioEngine.stop() recognitionRequest?.endAudio()

  37. Demo

  38. This app has crashed because it attempted to access privacy-sensitive

    data without a usage description. The app's Info.plist must contain an NSMicrophoneUsageDescription key with a string value explaining to the user how the app uses this data.
  39. Quais locales suportados?

  40. SFSpeechRecognizer.supportedLocales()

  41. SpeakToMe

  42. Perguntas?

  43. Obrigado!

  44. github.com/fpg1503