1. Enter the official website registration account, login, registration, application.
2, download the SDK Import System library.
3, Close Bitcode
4, initialize the voice of the message fly.
NSString * initstring = [[NSString alloc] initwithformat:@ "appid=%@", @ "56fb34f4"];
[Iflyspeechutility createutility:initstring];
5. Integration Code
#import <UIKit/UIKit.h>
#import "Iflymsc/iflyspeechconstant.h"
#import "Iflymsc/iflyspeechsynthesizer.h"
#import "Iflymsc/iflyspeechsynthesizerdelegate.h"
@interface viewcontroller:uiviewcontroller<iflyspeechsynthesizerdelegate>
{
Iflyspeechsynthesizer * _iflyspeechsynthesizer;
}
@end
#import "ViewController.h"
@interface Viewcontroller () <UITextFieldDelegate>
@property (Weak, nonatomic) Iboutlet Uitextfield *textfield;
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Additional setup after loading the view, typically from a nib.
Self.textField.delegate = self;
_iflyspeechsynthesizer = [Iflyspeechsynthesizer sharedinstance]; _iflyspeechsynthesizer.delegate =
Self
2. Setting Composition parameters
Set up how to work online
[_iflyspeechsynthesizer setparameter:[iflyspeechconstant Type_cloud]
Forkey:[iflyspeechconstant Engine_type]];
Volume, Value range 0~100
[_iflyspeechsynthesizer setparameter:@ "Forkey": [Iflyspeechconstant VOLUME]];
Pronunciation person, default to "XiaoYan", you can set the parameter list can refer to "Synthetic pronunciation person list" [_iflyspeechsynthesizer setparameter:@ "XiaoYan" Forkey: [ Iflyspeechconstant Voice_name]]; Save the composition file name, if no longer required, set to nil or null to cancel, default directory is located under Library/cache
[_iflyspeechsynthesizer setparameter:@ "TTS.PCM" Forkey: [Iflyspeechconstant Tts_audio_path]];
[_iflyspeechsynthesizer setparameter:@ "" Forkey:[iflyspeechconstant Voice_name]];
NSString * str = [iflyspeechconstant voice_name];
NSLog (@ "%@", str);
}
-(Ibaction) Voiceaction: (ID) Sender {
[Self.textfield Resignfirstresponder];
[_iflyspeechsynthesizer StartSpeaking:self.textField.text];
}
-(void) Touchesbegan: (Nsset *) touches withevent: (uievent *) event{
[Self.textfield Resignfirstresponder];
}
-(Ibaction) Endvoiceplay: (ID) Sender {
[_iflyspeechsynthesizer pausespeaking];
}
-(Ibaction) Resumeplay: (ID) Sender {
[_iflyspeechsynthesizer resumespeaking];
}
-(BOOL) Textfieldshouldreturn: (Uitextfield *) TextField
{
[TextField Resignfirstresponder];
[Self voiceaction:nil];
return YES;
}
End Agent
-(void) oncompleted: (Iflyspeecherror *) error{
NSLog (@ "End");
}
Synthesis begins
-(void) onspeakbegin{
NSLog (@ "synth start");
}
Synthesis Buffering Progress
-(void) onbufferprogress: (int) Progress message: (NSString *) msg
{
}
Composition Playback Progress
-(void) onspeakprogress: (int) progress{
}
iOS Development Audio Integration