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: 19 days 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: 2025-01-18T07:16:26.069Z (about 1 month 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: 181
- Watchers: 6
- Forks: 34
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SpeechRecognizerButton
[](http://twitter.com/alexruperez)
[](http://cocoapods.org/pods/SpeechRecognizerButton)
[](http://cocoapods.org/pods/SpeechRecognizerButton)
[](http://cocoapods.org/pods/SpeechRecognizerButton)
[](https://swift.org)
[](https://travis-ci.org/alexruperez/SpeechRecognizerButton)
[](https://github.com/Carthage/Carthage)
[](https://github.com/apple/swift-package-manager)UIButton subclass with push to talk recording, speech recognition and Siri-style waveform view.

## 📲 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.