• Stars
    star
    278
  • Rank 142,954 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Start recording when the user speaks

FDSoundActivatedRecorder

CI Status Version License Platform Carthage compatible Readme Score

Start recording when the user speaks. All you have to do is tell us when to start listening. Then we wait for an audible noise and start recording. This is mostly useful for user speech input and the "Start talking now" prompt.

๐Ÿ• Virtual tip jar: https://amazon.com/hz/wishlist/ls/EE78A23EEGQB

Features

  • You can start recording when sound is detected, or immediately
  • Sound stops recording when the user is done talking
  • Works with ARC and iOS 5+

Installation

Add this to your project using Swift Package Manager. In Xcode that is simply: File > Swift Packages > Add Package Dependency... and you're done. Alternative installation options are shown below for legacy projects.

CocoaPods

If you are already using CocoaPods, just add 'FDSoundActivatedRecorder' to your Podfile then run pod install.

Carthage

If you are already using Carthage, just add to your Cartfile:

github "fulldecent/FDSoundActivatedRecorder" ~> 0.1

Then run carthage update to build the framework and drag the built FDSoundActivatedRecorderframework into your Xcode project.

Usage

First, install by adding pod 'FDSoundActivatedRecorder', '~> 1.0.0' to your Podfile.

Import the project with:

import FDSoundActivatedRecorder

Then begin listening with:

self.recorder = FDSoundActivatedRecorder()
self.recorder.delegate = self
self.recorder.startListening()

A full implementation example is provided in this project.

If your app is in the app store, I would much appreciate if you could add your app to https://www.cocoacontrols.com/controls/fdsoundactivatedrecorder under "Apps using this control" and "I Use This Control".

Regular Recorder

If you want to use it as a regular recorder, without the ability to of trimming the audio.

  1. Begin listening:
self.recorder.startListening()
  1. Begin recording:
self.recorder.startRecording()
  1. Finally, you can stop recording using the following method:
self.recorder.stopAndSaveRecording()

Full API

The full API, from FDSoundActivatedRecorder.swift is copied below:

@objc protocol FDSoundActivatedRecorderDelegate {
ย  ย  /// A recording was triggered or manually started
ย  ย  func soundActivatedRecorderDidStartRecording(recorder: FDSoundActivatedRecorder)

ย  ย  /// No recording has started or been completed after listening for `TOTAL_TIMEOUT_SECONDS`
ย  ย  func soundActivatedRecorderDidTimeOut(recorder: FDSoundActivatedRecorder)

ย  ย  /// The recording and/or listening ended and no recording was captured
ย  ย  func soundActivatedRecorderDidAbort(recorder: FDSoundActivatedRecorder)

ย  ย  /// A recording was successfully captured
ย  ย  func soundActivatedRecorderDidFinishRecording(recorder: FDSoundActivatedRecorder, andSaved file: NSURL)
}

class FDSoundActivatedRecorder : NSObject {
ย  ย  /// A log-scale reading between 0.0 (silent) and 1.0 (loud), nil if not recording
ย  ย  dynamic var microphoneLevel: Double

ย  ย  /// Receiver for status updates
ย  ย  weak var delegate: FDSoundActivatedRecorderDelegate?

ย  ย  /// Listen and start recording when triggered
ย  ย  func startListening()

ย  ย  /// Go back in time and start recording `RISE_TRIGGER_INTERVALS` ago
ย  ย  func startRecording()

ย  ย  /// End the recording and send any processed & saved file to `delegate`
ย  ย  func stopAndSaveRecording()

ย  ย  /// End any recording or listening and discard any recorded files
ย  ย  func abort()

ย  ย  /// This is a PRIVATE method but it must be public because a selector is used in NSTimer (Swift bug)
ย  ย  func interval()
}

Technical discussion

This library is tuned for human speech detection using Apple retail iOS devices in a quiet or noisy environement. You are welcome to tune the audio detection constants of this program for any special needs you may have. Following is a technical description of how the algorithm works from FDSoundActivatedRecorder.swift.

V ย  ย  ย  ย  ย  ย  ย  Recording
O ย  ย  ย  ย  ย  ย  /-----------\
Lย  ย  ย  ย  ย  ย  / ย  ย  ย  ย  ย  ย  \Fall
U ย  ย  ย  ย  ย  /Rise ย  ย  ย  ย  ย  \
Mย  ย  ย  ย  ย  / ย  ย  ย  ย  ย  ย  ย  ย  \
Eย  -------- ย  ย  ย  ย  ย  ย  ย  ย  ย  --------
 ย  Listeningย  ย  ย  ย  ย  ย  ย  ย  ย  Done
  • We listen and save audio levels every INTERVAL
  • When several levels exceed the recent moving average by a threshold, we record
  • (The exceeding levels are not included in the moving average)
  • When several levels deceed the recent moving average by a threshold, we stop recording
  • (The deceeding levels are not included in the moving average)

Sponsorship

[ YOUR LOGO HERE ]

Please contact [email protected] to discuss adding your company logo above and supporting this project.

More Repositories

1

system-bus-radio

Transmits AM radio on computers without radio transmitting hardware.
C
6,115
star
2

FDWaveformView

Reads an audio file and displays the waveform
Swift
1,202
star
3

swift5-module-template

An opinionated starting point for awesome, reusable Swift 5 modules
Swift
437
star
4

FDTake

Easily take a photo or video or choose from library
Swift
322
star
5

corelocationcli

Command line program to print location information from CoreLocation
Swift
206
star
6

FDChessboardView

An iOS / Mac view controller for chess boards
Swift
77
star
7

formant-analyzer

iOS application for finding formants in spoken sounds
Swift
51
star
8

spend-ERC20-create-ERC721

Tech demo: customers spend your ERC-20 tokens to create their ERC-721 certificates
Solidity
49
star
9

cameralife

Camera Life -- Run your own photo website
PHP
40
star
10

github-pages-template

An opinionated starting point and build system for awesome, collaboratively-edited HTML websites
JavaScript
31
star
11

opensea-shared-storefront-backdoor

Demonstration of a backdoor in OpenSea Shared Storefront
JavaScript
30
star
12

FDTextFieldTableViewCell

A UITableViewCell with an editable text field
Swift
26
star
13

FDBarGauge

The successor to F3BarGauge
Swift
25
star
14

google-voice-numbers

Retrieves the full list of available Google Voice numbers and finds the best ones
HTML
24
star
15

erc721-example

A scalable example of the ERC-721 standard
Solidity
19
star
16

solidity-template

The starting point for every Solidity project
Solidity
18
star
17

19-questions

A machine learning / bayesian inference engine assigning attributes to objects
PHP
16
star
18

eavesdrop

Listen in on TCP conversations on the network your computer is attached to
Objective-C
16
star
19

google-sheets-etl

Live import all your Google Sheets to your data warehouse
PHP
15
star
20

8-ball

A delightfully simple iOS + watchOS app for answering questions
Swift
14
star
21

freescout-sidebar-webhook

Sidebar Webhook asynchronously injects HTML from your server into conversation sidebars
PHP
14
star
22

philadelphia-traffic-court-rtk

Every traffic violation in the city of Philadelphia issued from 2006 to 2014
Python
12
star
23

pro-penetration

Penetration research against NSFW websites
PHP
11
star
24

structured-acceptance-test

An open format definition for static analysis tools
Ruby
10
star
25

lightning-sites

โ˜๏ธ Lightning deployment for your ~/Sites folders
Ruby
10
star
26

footballbetting

Automatically exported from code.google.com/p/footballbetting
9
star
27

pizzaman

The iOS game
Swift
8
star
28

contract-scanner

A tool to find all NFT contracts on an EVM blockchain
JavaScript
6
star
29

linkbuilding-spider

A PHP project to check if websites are linking to your website
PHP
6
star
30

web-puc

Validate your web project uses the latest CSS & JS includes
Ruby
6
star
31

custodial721

A token that holds other tokens / Can also create and transfer 721s in batch
5
star
32

pawn-bfs

A breadth-first enumeration of all reachable chess diagrams
C
5
star
33

solidity-monolithic-flattener

A tool to flatten solidity contracts for runtime optimization
4
star
34

thin-pdo

A minimal wrapper for PHP's PDO class to make database access easier
PHP
3
star
35

fedex-ship-manager-api

Documentation for hidden FedEx Ship Managerยฎ API
HTML
3
star
36

voicemail-remote

Continuously update your voicemail outgoing message
Shell
3
star
37

live-testing-with-estimateGas

Code examples from the article published with 0xcert
HTML
3
star
38

aion-aip040

Reference implementation for Aion non-fungible tokens
Java
3
star
39

podcast.phor.net

HTML
2
star
40

html-proofer-mailto_awesome

A custom html-proofer test that makes your mailto links awesome
Ruby
2
star
41

chess-upper-bound-armies

An upper bound of Chess positions by counting army configurations
C
2
star
42

wrapped-number-board

Solidity
2
star
43

Nineteen-Eighty-Five

A novel by William Entriken, based on the public domain work of George Orwell
CSS
2
star
44

tmp-swift5-module

Swift
2
star
45

versioned_database_template

A demonstration of versioned, hashable, attestable databases
2
star
46

sillyutility.net

Compare Utility Bills With Neighbors.
HTML
2
star
47

echo

The best way to practice speaking English or Spanish
Swift
2
star
48

alephcrypto.xyz

https://alephcrypto.xyz
HTML
2
star
49

septa-regionalrail-otp

These reports use every train's arrival time from 2009 until present to recommend schedule changes for chronically late service
HTML
2
star
50

you-cant-leave-this-page

Proof of concept where you can't leave a web page
HTML
1
star
51

phor.net

HTML
1
star
52

open-location-code-wiki

1
star
53

vulnerability-demo.justjavac.com

https://privacylog.blogspot.com/2021/04/upcoming-event-zero-day-live-2021-05-01.html
1
star
54

e-zpass-v-toll-batch-dispute

Documentation to quickly dispute E-ZPass V-TOLL violations
1
star
55

jump-qrs

QR codes which redirect to a destination website as configured in this repository
HTML
1
star
56

rubygems-issue-6214

1
star
57

beginner-project-php-sql

You will learn to create your first meaningful PHP project which connects to a database
1
star
58

blog.phor.net

William Entriken Blog โ€” Analysis of all
CSS
1
star
59

aip-xxx-implementation

Java playground illustrating all best practices for Aion development
Java
1
star
60

blackjack-simulator

JavaScript implementation of blackjack rules and player betting strategies
C
1
star
61

qr-radiation

An optimizer that makes your QR code look like a target graphic by manipulating your URL
JavaScript
1
star
62

impostor

Who's the impostor?
HTML
1
star