iOS SDK Guide

Get Started with the iOS SDK

  1. Send a request to developer@speebly.com to register a new Speebly Client 
  2. Copy the generated Client ID and Client Key for your selected client.
  3. Follow the instructions below to install the iOS SDK into your app.

Available downloads:

  • Speebly iOS SDK
  • Swift Sample App (includes a basic UI)

System Requirements

  • iOS 13+
  • XCode 11+

Package Contents

  • SpeeblySDK.framework

Core Tasks

  • Voice Query – Make voice queries against the Speebly servers. Transcriptions and results will be returned as an object. The SDK will control the audio session for the application.

Related methods and delegates:

  • SpeeblyVoiceQuery -startListeningWithCompletionHandler:
    • didStateChange: delegate that is called to represent microphone state changes 
    • didReceiveQueryResult: delegate that is called when speebly voice Query is finished
    • didReceivePartialTranscription: delegate that is called during voice transcription
  • Text Query – Allows text-based queries against Speebly servers. Results are delivered in the same format as a voice query.
    • Related methods:
      • SpeeblyTextQuery -newTextSearchWithSearchText:

Installation

Cocoapods

Add the following line to your Podfile

pod SpeeblySDK

And run pod install in your command line.

Setup

Step 1) Add the import statement where you intend to call the Speebly SDK

Swift:

import SpeeblySDK

Step 2) Call setClientID

Add to AppDelegate.swift

Swift:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    Speebly.setClientID("<INSERT YOUR CLIENT ID>");                    
    Speebly.setClientKey("<INSERT YOUR CLIENT KEY>");
    …
}

Step 3. Add the following code snippet to your info.plist file.

<key>NSMicrophoneUsageDescription</key>
<string>YOUR_PERMISSION_COPY</string>

Step 4. Start calling methods in the Speebly SDK.

How to Perform a Voice Query

Speebly Voice Query: An Overview

After a voice query is started, the first phase of its life cycle is Recording. During the Recording phrase, the SDK is ingesting audio from the device’s microphone. The SDK streams this audio to Speebly, which continuously generates transcriptions of the audio and returns them to the SDK. These partial transcriptions are made available to the application via the delegate method -speeblyVoiceQuery:didReceivePartialTranscription:

By default, the SDK will automatically detect when the user has finished speaking and end the Recording phase. Alternatively, the application may end the Recording phase explicitly by calling SpeeblyVoiceQuery -stopRecording

The Intent Identification phase follows the Recording phase. During this phase, the Speebly Voice Server sends the query to your Google DialogFlow agent. It understands the user’s query and concludes the intent by delivering a response. The SDK makes this response available to the application via the delegate method -speeblyVoiceQuery:didReceiveQueryResult:dictionary:

The query response initiates a Speaking phase where the response is played using system audio. This is using SpeeblyQueryResult. The query result also includes other properties that can be leveraged. 

When Speaking is complete, the query is Finished.

Sample Implementation

import SpeeblySDK

class SpeeblyStore: SpeeblyVoiceSearchDelegate {
   
    var isStarted: Bool = false
    var mySpeebly:Speebly? = nil
  
    //starts voice query. this method is called from a button or a siri shortcut
    func startSpeeblyVoiceQuery(eventName:String) {
        self.isStarted = true
        self.mySpeebly = Speebly()
        self.mySpeebly?.delegate = self
        mySpeebly?.startListeningWithCompletionHandler(eventName: eventName)
    }
    
    //stops voice query, this methed  is called from a button or when an error has occured
    func stopSoeeblyVoiceQuery (){
       if self.mySpeebly != nil {
           self.mySpeebly?.stop()
       }
    }
    
    // speebly voice query delegate
    // didStateChange is called when the state changes
    func didStateChange(state: String) {
        print("state" + state)
    }
    
    // speebly voice query delegate
    // didReceiveQueryResult is called when voice/text query is completed
    func didReceiveQueryResult(speeblyQueryResult: SpeeblyResponse) {
        print("this is the result from voice or text query" + speeblyQueryResult )
    }
    
    // speebly voice query delegate
    // didReceivePartialTranscription is called during the transctiption stage
    func didReceivePartialTranscription(partialTranscription: String) {
       print("didReceivePartialTranscription  displays the realtime results of the speech to text transcription" + partialTranscription)
    }
    
}