Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexruperez/SpeechRecognizerButton
UIButton subclass with push to talk recording, speech recognition and Siri-style waveform view.
https://github.com/alexruperez/SpeechRecognizerButton
carthage ios push-to-talk record-audio siri speech-recognition speech-to-text swift uibutton uibutton-subclass waveform
Last synced: about 1 month ago
JSON representation
UIButton subclass with push to talk recording, speech recognition and Siri-style waveform view.
- Host: GitHub
- URL: https://github.com/alexruperez/SpeechRecognizerButton
- Owner: alexruperez
- License: mit
- Created: 2018-02-26T16:16:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-15T14:42:37.000Z (over 5 years ago)
- Last Synced: 2024-10-21T04:09:28.715Z (2 months ago)
- Topics: carthage, ios, push-to-talk, record-audio, siri, speech-recognition, speech-to-text, swift, uibutton, uibutton-subclass, waveform
- Language: Swift
- Homepage:
- Size: 580 KB
- Stars: 179
- Watchers: 6
- Forks: 35
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cocoa - SpeechRecognizerButton
README
# SpeechRecognizerButton
[![Twitter](https://img.shields.io/badge/[email protected]?style=flat)](http://twitter.com/alexruperez)
[![Version](https://img.shields.io/cocoapods/v/SpeechRecognizerButton.svg?style=flat)](http://cocoapods.org/pods/SpeechRecognizerButton)
[![License](https://img.shields.io/cocoapods/l/SpeechRecognizerButton.svg?style=flat)](http://cocoapods.org/pods/SpeechRecognizerButton)
[![Platform](https://img.shields.io/cocoapods/p/SpeechRecognizerButton.svg?style=flat)](http://cocoapods.org/pods/SpeechRecognizerButton)
[![Swift](https://img.shields.io/badge/Swift-5-orange.svg?style=flat)](https://swift.org)
[![Build Status](https://travis-ci.org/alexruperez/SpeechRecognizerButton.svg?branch=master)](https://travis-ci.org/alexruperez/SpeechRecognizerButton)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift Package Manager Compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-4BC51D.svg?style=flat)](https://github.com/apple/swift-package-manager)UIButton subclass with push to talk recording, speech recognition and Siri-style waveform view.
![SpeechRecognizerButton](https://github.com/alexruperez/SpeechRecognizerButton/raw/master/SpeechRecognizerButton.gif)
## 📲 Installation
SpeechRecognizerButton is available through [CocoaPods](http://cocoapods.org). To install it,
simply add the following line to your Podfile:```ruby
pod 'SpeechRecognizerButton'
```#### Or you can install it with [Carthage](https://github.com/Carthage/Carthage):
```ogdl
github "alexruperez/SpeechRecognizerButton"
```#### Or install it with [Swift Package Manager](https://swift.org/package-manager/):
```swift
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:
```swift
button.authorizationErrorHandling = .openSettings(completion: ...)
```#### Custom handling:
```swift
button.authorizationErrorHandling = .custom(handler: { error in
// TODO: Your code here!
})
```### Handling results:
```swift
button.resultHandler = { recordURL, speechRecognitionResult in
// TODO: Your code here!
}
```### Handling errors:
```swift
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.
```swift
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.
```swift
waveformView.waveColor = ...
waveformView.numberOfWaves = ...
waveformView.primaryWaveLineWidth = ...
waveformView.secondaryWaveLineWidth = ...
waveformView.idleAmplitude = ...
waveformView.frequency = ...
waveformView.density = ...
waveformView.phaseShift = ...
waveformView.amplitude = ...
```## ❤️ Etc.
* [SFWaveformView](https://github.com/alexruperez/SpeechRecognizerButton/blob/master/SpeechRecognizerButton/SFWaveformView.swift#L6) based on [jyunderwood](https://github.com/jyunderwood)/[WaveformView-iOS](https://github.com/jyunderwood/WaveformView-iOS), thanks!
* Contributions are very welcome.
* Attribution is appreciated (let's spread the word!), but not mandatory.## 👨💻 Authors
[alexruperez](https://github.com/alexruperez), [email protected]
## 👮♂️ License
SpeechRecognizerButton is available under the MIT license. See the LICENSE file for more info.