iOS Development Audio Integration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.