Giter VIP home page Giter VIP logo

speechrecognizerbutton's Introduction

SpeechRecognizerButton

Twitter Version License Platform Swift Build Status Carthage compatible Swift Package Manager Compatible

UIButton subclass with push to talk recording, speech recognition and Siri-style waveform view.

SpeechRecognizerButton

๐Ÿ“ฒ Installation

SpeechRecognizerButton is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SpeechRecognizerButton'

Or you can install it with Carthage:

github "alexruperez/SpeechRecognizerButton"

Or install it with Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/alexruperez/SpeechRecognizerButton.git")
]

๐Ÿ’ Usage

Configuration:

Add NSMicrophoneUsageDescription and NSSpeechRecognitionUsageDescription keys to your Info.plist file containing a description of how your app will use the voice recording and speech recognition.

Handling authorization:

Automatically opening Settings when denying permission:

button.authorizationErrorHandling = .openSettings(completion: ...)

Custom handling:

button.authorizationErrorHandling = .custom(handler: { error in
  // TODO: Your code here!
})

Handling results:

button.resultHandler = { recordURL, speechRecognitionResult in
  // TODO: Your code here!
}

Handling errors:

button.errorHandler = { error in
  // TODO: Your code here!
}

Assigning waveform view:

Just set weak var waveformView: SFWaveformView? property or use the Interface Builder outlet.

Assigning activity indicator view:

Just set weak var activityIndicatorView: UIActivityIndicatorView? property or use the Interface Builder outlet.

Customizing SFButton configuration:

Just set the following properties by code or use the Interface Builder inspectables.

button.audioSession...
button.recordURL = ...
button.audioFormatSettings = [AV...Key: ...]
button.maxDuration = ...
button.locale = Locale....
button.taskHint = SFSpeechRecognitionTaskHint....
button.queue = OperationQueue....
button.contextualStrings = ["..."]
button.interactionIdentifier = "..."
button.animationDuration = ...
button.shouldVibrate = ...
button.shouldSound = ...
button.pushToTalk = ...
button.speechRecognition = ...
button.cancelOnDrag = ...
button.shouldHideWaveform = ...
button.cornerRadius = ...
button.borderColor = ...
button.borderWidth = ...
button.selectedColor = ...
button.highlightedColor = ...
button.disabledColor = ...
button.highlightedAlpha = ...

Customizing SFWaveformView configuration:

Just set the following properties by code or use the Interface Builder inspectables.

waveformView.waveColor = ...
waveformView.numberOfWaves = ...
waveformView.primaryWaveLineWidth = ...
waveformView.secondaryWaveLineWidth = ...
waveformView.idleAmplitude = ...
waveformView.frequency = ...
waveformView.density = ...
waveformView.phaseShift = ...
waveformView.amplitude = ...

โค๏ธ Etc.

๐Ÿ‘จโ€๐Ÿ’ป Authors

alexruperez, [email protected]

๐Ÿ‘ฎโ€โ™‚๏ธ License

SpeechRecognizerButton is available under the MIT license. See the LICENSE file for more info.

speechrecognizerbutton's People

Contributors

alexruperez avatar dieu avatar jiawen-zhang avatar spectraldragon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.