Coder Social home page Coder Social logo

jpoliachik / ios-voice-processor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from picovoice/ios-voice-processor

0.0 0.0 0.0 153 KB

Asynchronous iOS audio recording library designed for real-time speech audio processing

License: Apache License 2.0

Ruby 4.51% Swift 95.49%

ios-voice-processor's Introduction

iOS Voice Processor

GitHub release GitHub

Cocoapods

Made in Vancouver, Canada by Picovoice

Twitter URL

YouTube Channel Views

The iOS Voice Processor is an asynchronous audio capture library designed for real-time audio processing. Given some specifications, the library delivers frames of raw audio data to the user via listeners.

Table of Contents

Requirements

Compatibility

  • iOS 11.0+

Installation

iOS Voice Processor is available via CocoaPods. To import it into your iOS project, add the following line to your Podfile:

pod 'ios-voice-processor'

Permissions

To enable recording with your iOS device's microphone you must add the following to your app's Info.plist file:

<key>NSMicrophoneUsageDescription</key>
<string>[Permission explanation]</string>

See our example app or this guide for how to properly request this permission from your users.

Usage

Access the singleton instance of VoiceProcessor:

import ios_voice_processor

let voiceProcessor = VoiceProcessor.instance

Add listeners for audio frames and errors:

let frameListener = VoiceProcessorFrameListener { frame in
    // use audio
}

let errorListener = VoiceProcessorErrorListener { error in
    // handle error
}

voiceProcessor.addFrameListener(frameListener);
voiceProcessor.addErrorListener(errorListener);

Start audio capture with the desired frame length and audio sample rate:

do {
    try voiceProcessor.start(frameLength: 512, sampleRate: 16000);
} catch {
    // handle start error
}

Stop audio capture:

do {
    try voiceProcessor.stop();
} catch {
}

Once audio capture has started successfully, any frame listeners assigned to the VoiceProcessor will start receiving audio frames with the given frameLength and sampleRate.

Capturing with Multiple Listeners

Any number of listeners can be added to and removed from the VoiceProcessor instance. However, the instance can only record audio with a single audio configuration (frameLength and sampleRate), which all listeners will receive once a call to start() has been made. To add multiple listeners:

let listener1 = VoiceProcessorFrameListener({_ in })
let listener2 = VoiceProcessorFrameListener({_ in })
let listeners: [VoiceProcessorFrameListener] = [listener1, listener2];

voiceProcessor.addFrameListeners(listeners);

voiceProcessor.removeFrameListeners(listeners);
// or
voiceProcessor.clearFrameListeners();

Example

The iOS Voice Processor app demonstrates how to ask for user permissions and capture output from the VoiceProcessor.

Releases

v1.1.0 - July 31, 2023

  • Numerous API improvements
  • Error handling improvements
  • Allow for multiple listeners instead of a single callback function
  • Upgrades to testing infrastructure and example app

v1.0.0 - August 5, 2021

  • Initial public release.

ios-voice-processor's People

Contributors

laves avatar ksyeo1010 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.