将文字转成语音,步骤和什么类似,直接上代码
//第一步:引入头文件
//文字识别的回调方法接口
#import <iflyMSC/IFlySpeechSynthesizerDelegate.h>
//文字识别对象
#import <iflyMSC/IFlySpeechSynthesizer.h>
//科大讯飞语音框架定义的常量
#import <iflyMSC/IFlySpeechConstant.h>
//延展
@interface SecondViewController ()<IFlySpeechSynthesizerDelegate>
//显示文字(插座变量)
@property (weak, nonatomic) IBOutlet UITextView *inputContentTextView;
//文字识别对象
@property (strong, nonatomic) IFlySpeechSynthesizer *synthesizer;
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//创建文字识别对象(单例方法)
self.synthesizer = [IFlySpeechSynthesizer sharedInstance];
//指定文字识别对象的代理对象
self.synthesizer.delegate = self;
//设置文字识别对象的关键属性
[self.synthesizer setParameter:@"50" forKey:[IFlySpeechConstant SPEED]];
[self.synthesizer setParameter:@"50" forKey:[IFlySpeechConstant VOLUME]];
[self.synthesizer setParameter:@"XIAOYAN" forKey:[IFlySpeechConstant VOICE_NAME]];
[self.synthesizer setParameter:@"8000" forKey:[IFlySpeechConstant SAMPLE_RATE]];
[self.synthesizer setParameter:@"temp.pcm" forKey:[IFlySpeechConstant TTS_AUDIO_PATH]];
[self.synthesizer setParameter:@"custom" forKey:[IFlySpeechConstant PARAMS]];
}
#pragma mark - 识别相关的内容
- (IBAction)beginRecongnise:(id)sender {
[self.synthesizer startSpeaking:_inputContentTextView.text];
}
#pragma mark - 代理方法
- (void)onCompleted:(IFlySpeechError *)error {
NSLog(@"么么哒");
}
@end