This Natural Voice Mobile SDK is a native iOS library to quickly integrate voice feedback and voice-to-text data streams into your applications https://docs.aimmatic.com/apis/#ios-sdk-quick-start
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
NaturalVoice
.gitignore
.travis.yml
LICENSE
NaturalVoice.podspec
README.md
_Pods.xcodeproj

README.md

Natural Voice Mobile SDK For iOS

This library allows you to integrate Natural Voice functions into your iOS app.

Requires API key. For a free API key you may contact our solution desk.

https://www.aimmatic.com/solution-desk.html

mailto:solution.desk@aimmatic.com

Please allow a few hours for a response.

Feature

Example:

Usage

Requirements

• iOS 8.0+

• xCode 9

Cocoapods

pod 'NaturalVoice'

Install

pod install

Info.plist

Natural Voice requires location service and microphone permission, you need to add these keys to Info.plist

<key>NSMicrophoneUsageDescription</key>
<string>YOUR_DESCRIPTION</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>YOUR_DESCRIPTION</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>YOUR_DESCRIPTION</string>

Add your ApiKey in Info.plist

<key>AimMaticNaturalVoiceApiKeyDescription</key>
<string>YOUR_API_KEY</string>

Using Voice Service

Get supported languages

VoiceLanguageManager.shared.getSupportLanguages { (languages: [VoiceLanguage]) in

}

Configuration

VoiceRecordStrategy.language = language
VoiceRecordStrategy.maxRecordDuration = 30
VoiceRecordStrategy.maxRecordDurationPolicy = .sendImmediately
VoiceRecordStrategy.speechTimeout = 2
VoiceRecordStrategy.speechTimeoutPolicy = .sendImmediately

Start recording

VoiceRecorder.shared.startRecording(recordStarted: { meta in

}, recordEnded: { response in

}, recordSent: { response in

}, recordFailed: { error in

})

Block handle

When recording is started

let recordStared: VoiceRecordStarted = { (meta: VoiceFileMeta?) in

}

When recording is finished

let recordEnded: VoiceRecordEnded = { (response: VoiceRecordEndResponse?) in
            
}

When recording is sent

let recordSent: VoiceRecordSent = { (response: VoiceRecordSendResponse?) in
            
}

When recording is failed

let recordFailed: VoiceRecordFailed = { (error: Error?) in
            
}

Handle policy .userChoice when recording is finished

if response?.policy == .userChoice {
    let controller = UIAlertController(title: "Send or Abort?", message: nil, preferredStyle: .alert)
    controller.addAction(UIAlertAction(title: "Send", style: .default, handler: { action in
        /* Send recorded file */
        response?.send()
    }))
    controller.addAction(UIAlertAction(title: "Abort", style: .cancel, handler: { action in
        /* Abort sending recorded file */
        response?.abort()
    }))
    self.present(controller, animated: true, completion: {})             
}

Stop recording

This will override policy that was set in

VoiceRecordStrategy.maxRecordDurationPolicy

Stop with decision

VoiceRecorder.shared.stopRecording(policy: .userChoice)

Stop and send immediately

VoiceRecorder.shared.stopRecording(policy: .sendImmediately)

Stop and cancel sending

VoiceRecorder.shared.stopRecording(policy: .cancel)