iOS SDK

The Speech-i iOS SDK provides APIs to easily integrate Speech Recognition features into iOS apps. The API automatically handles websocket access to speech server, audio capture, encoding, trasmission and transcription retrieval in real-time.

The SDK can be used both Objective-C and SWIFT projects, and requires iOS Deployment Target 8.0 or higher.

 Get Started

  1. Download the latest SDK version here.

  2. In Xcode, choose the project and select your target. Then in Tab Embedded Binaries click on the + button, select Add Other and choose the downloaded file CedatSTT.framework. Verify that Copy items if needed is checked and click Finish.


  3. Check the framework presence in Tab Embedded Binaries and in Tab Linked Frameworks and Libraries


 Usage

Import the framework in your view controller

import CedatSTT
#import <CedatSTT/CedatSTT.h>

Setup the Api Key and register to delegate CedatSTTManagerDelegate

class ViewController: UIViewController {
	override func viewDidLoad() {
		super.viewDidLoad()
		// Do any additional setup after loading the view, typically from a nib.
		let manager = CedatSTTManager.shared()
		manager.apiKey = "YOUR_API_KEY"
		manager.delegate = self
	}
}

extension ViewController: CedatSTTManagerDelegate {
	func cedatSTTManager( _ manager: CedatSTTManager, didRecognizeAudioWith hypotheses: [CedatSTTHypothesis]) {
		// Print transcription results
		for ipotesi in hypotheses{
			print("Transcript: \(ipotesi.transcript) - Confidence: \(ipotesi.confidence)")
		}
	}

	func cedatSTTManager( _ manager: CedatSTTManager, didFailRecognizeAudioWithError error: String) {
		// Print the error
		print("Errore: \(error)" )
	}
	
	func cedatSTTManager( _ manager: CedatSTTManager, didRecognizePartialAudioWith partialRecognizedText: String) {
		// Print partial transcription results
		print ("Testo parziale: \(partialRecognizedText)")
	}
	func cedatSTTManager( _ manager: CedatSTTManager, didChangeVolumeWithDecibels decibels: float) {
		// Print decibel value
		print ("Decibels: \(decibels)")
	}
}
@interface ViewController()
@end
- (void)viewDidLoad {
	[super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
	CedatSTTManager *manager = [CedatSTTManager shared];
	[manager setApiKey: @""]
	manager.delegate = self;
}

#pragma mark - CedatSTTManagerDelegate methods

- (void)cedatSTTManager:(CedatSTTManager *)manager didRecognizeAudioWith:(NSArray < CedatSTTHypothesis
*> *)hypotheses{
	// Print transcription results
	for (CedatSTTHypothesis *ipotesi in hypotheses) {
		NSLog(@"Transcript: %@ - Confidence: %f" , ipotesi.transcript , ipotesi.confidence);
	}
}

- (void)cedatSTTManager:(CedatSTTManager *)manager didFailRecognizeAudioWithError:(NSString *)error{
	// Stampiamo nei log il messaggio di errore
	NSLog(@"Error: %@", error);
}

- (void)cedatSTTManager:(CedatSTTManager *)manager didRecognizePartialAudioWith:(NSString
*)partialRecognizedText{
	// Print partial transcription results
	NSLog(@"Partial result: %@" ,partialRecognizedText);
}

- ( void )cedatSTTManager:( CedatSTTManager *)manager didChangeVolumeWithDecibels:( float) decibels{
	// Print decibel value
	NSLog(@"Decibels: %.2f" , decibels);
}

Show the voice recognition UI and customize parameters

//...
@IBAction func showVoiceRecognition( _ sender: Any) {
	let manager = CedatSTTManager.shared()
	// customize parameters
	manager. prompt = "Speak now"
	if let controller = manager.cedatSTTViewController {
		present (controller, animated:true, completion:nil)
	}
}
//...
//...
- (IBAction)showVoiceRecognition:(id)sender{
	CedatSTTManager *manager = [CedatSTTManager shared];
	// customize parameters here
	manager. prompt = @"Speak now" ;
	UIViewController *controller = [manager cedatSTTViewController];
	if (controller != nil) {
		[self presentViewController:controller animated:YES completion:nil];
	}
}
//...

Or use the voice recognition in your app usage without the predefined user interface

@IBAction func startVoiceRecognition( _ sender: Any) {
	let manager = CedatSTTManager.shared()
	manager.startRecognize()
}

@IBAction func stopVoiceRecognition(_sender: Any) {
	let manager = CedatSTTManager.shared()
	manager.stopRecognize()
}

@IBAction func checkVoiceRecognitionStatus(_sender: Any) {
	let manager = CedatSTTManager.shared()
	if manager.isRecognizing() {
		print("recognizing")
	}
	else {
		print("not recognizing")
	}
}
- (IBAction)startVoiceRecognition:(id)sender{
	CedatSTTManager *manager = [CedatSTTManager shared];
	[manager startRecognize];
}

- (IBAction)stopVoiceRecognition:(id)sender{
	CedatSTTManager *manager = [CedatSTTManager shared];
	[manager stopRecognize];
}

- (IBAction)checkVoiceRecognitionStatus:(id)sender{
	CedatSTTManager *manager = [CedatSTTManager shared];
	if ([manager isRecognizing]) {
		NSLog(@"recognizing");
	}
	else {
		NSLog(@"not recognizing");
	}
}

 Configuration

The library can be easily customized specifying the parameters defined in the CedatSTTManager class.

The only mandatory parameter is apiKey, which must be filled with the api key provided by Cedat 85.

Other parameters are optional and provide a default value if not specified.

The following table shows the customizable parameter from class CedatSTTManager.

PARAMETER TYPE DEFAULT DESCRIPTION
apiKey String Mandatory parameter Mandatory api key provided by Cedat 85
prompt String “Parla ora” Prompt for the user
maxResults int 1 Max number of results
minSilence float 2.0f Silence seconds to terminate the speech recognition
decoderUrl String ws://voicenote.trascrivi.com/ws/client/speech Server URL.
languageModel String it-IT_8k Language model:

en-GB_8k
en-US_8k
it-IT_8k
es-ES_8k
pt-PT_8k
pt-BR_8k