Latest 1.0.2
Homepage https://github.com/MQL9011/BaiduTTS
License MIT
Platforms ios 8.0
Frameworks GLKit, SystemConfiguration, AudioToolbox, AVFoundation, CFNetwork, CoreLocation, CoreTelephony
Authors

百度语音合成TTS离线二次封装

百度官方的SDK不支持cocoapods集成,所以就有了这个库. 其中官方的SDK中有个静态库libBaiduSpeechSDK.a比较大有200M+, 用了git lfs 才传上来 pod installs时估计也会比较久,请耐心等待.
APPID,APPKEY,SecretKey这三个请自行去百度云官网上申请,语音TTS是免费的.
我自己主要是将百度SDK做了二次封装,简化了调用方式,并且支持cocoapods集成.

Installation

pod 'BaiduTTS'

How to Use

  • 支持 男声, 女声, 语速快慢
//初始化
- (void)setUpTTS{
NSString* APP_ID = @"";
NSString* API_KEY = @"";
NSString* SECRET_KEY = @"";
self.tts = [[BaiduTTS alloc]initWithAppID:APP_ID ApiKey:API_KEY SecretKey:SECRET_KEY];
self.tts.delegate = self;
}

/**
开始播放
*/
- (void)playTTS{
self.tts.text = self.tv.text;
[self.tts startSpeech];
}

/**
暂停播放
*/
- (void)pauseTTS{
[self.tts ttsPause];
}

/**
继续播放
*/
- (void)resumeTTS{
[self.tts ttsResume];
}

/**
停止播放
*/
- (void)stopTTS{
[self.tts stopSpeech];
}
  • 代理回调,其中当前朗读位置可以通过已经朗读的长度来获取
#pragma mark TTS代理回调
/**
开始朗读
*/
- (void)speechStartSentence{
NSLog(@"开始朗读");
}

/**
朗读结束
*/
- (void)speechEndSentence{
NSLog(@"朗读结束");
}

/**
朗读取消
*/
- (void)speechCancel{
NSLog(@"朗读取消");
}

/**
下一批文字长度
*/
- (void)newDataArrived:(NSNumber *)length{
NSLog(@"新数据长度:%@",length);
}

/**
当前已经朗读的长度
*/
- (void)currentTextSpeakLengthChanged:(NSNumber *)length{
NSLog(@"已经朗读的长度:%@",length);
}

Author

[email protected]

License

BaiduTTS is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "BaiduTTS",
    "version": "1.0.2",
    "summary": "u767eu5ea6u8bedu97f3TTS cocoapods",
    "description": "u767eu5ea6u8bedu97f3TTS u5b98u65b9u53eau6709u624bu52a8u96c6u6210u65b9u5f0f,u6240u4ee5u5c31u6709u4e86u8fd9u4e2a,u65b9u4fbfu901au8fc7cocoapodsu65b9u5f0fu96c6u6210.",
    "homepage": "https://github.com/MQL9011/BaiduTTS",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "[email protected]"
    },
    "source": {
        "git": "https://github.com/MQL9011/BaiduTTS",
        "tag": "1.0.2"
    },
    "social_media_url": "http://cocomccree.cn/",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "BaiduTTS/Classes/**/*",
    "public_header_files": "BaiduTTS/Classes/BaiduTTS.h",
    "vendored_libraries": "BaiduTTS/Classes/BDSClientLib/*.a",
    "resource_bundles": {
        "BaiduTTS": [
            "BaiduTTS/Assets/*.dat"
        ]
    },
    "frameworks": [
        "GLKit",
        "SystemConfiguration",
        "AudioToolbox",
        "AVFoundation",
        "CFNetwork",
        "CoreLocation",
        "CoreTelephony"
    ],
    "libraries": [
        "sqlite3.0",
        "iconv.2.4.0",
        "c++",
        "z.1.2.5"
    ]
}

Pin It on Pinterest

Share This