commit
aa84aa2e42
111
README.md
111
README.md
@ -1,69 +1,42 @@
|
||||
# 科大讯飞的语音听说读写的cordova插件
|
||||
|
||||
## 安装方法
|
||||
|
||||
下载插件与官方SDK,android与ios的SDK需要分别建立项目下载SDK
|
||||
|
||||
|
||||
下载之后找到插件下
|
||||
|
||||
ios目录:src/ios
|
||||
|
||||
android目录:src/android/libs
|
||||
|
||||
|
||||
然后将SDK目录下
|
||||
|
||||
ios SDK:lib/iflyMSC.framework
|
||||
|
||||
android SDK:libs
|
||||
|
||||
分别替换插件的ios目录和android目录中的文件
|
||||
|
||||
将android SDK assets\iflytek目录中的文件替换插件中src/android/assets/iflytek路径下的文件
|
||||
|
||||
|
||||
|
||||
|
||||
然后修改plugin.xml,
|
||||
搜索app_id,将后面的值换成自己申请的appid
|
||||
|
||||
修改src/ios/CDVSpeech.m,
|
||||
搜索app_id,将后面的值换成自己申请的appid
|
||||
|
||||
运行cordova plugin add [插件的绝对路径] 或者 提交后的 git 地址
|
||||
|
||||
## 调用方法
|
||||
|
||||
|
||||
/** 开始录音 最大持续时间40秒
|
||||
* @Param 成功callback
|
||||
* @Param 失败callback
|
||||
* @Param 是否显示录音画面
|
||||
* @Param 是否显示标点
|
||||
*
|
||||
*/
|
||||
xunfeiListenSpeaking.startListen(success, error, isShowDialog, isShowPunc);
|
||||
|
||||
// 停止录音
|
||||
xunfeiListenSpeaking.stopListen();
|
||||
|
||||
/**
|
||||
* 开始说话
|
||||
* @Param 成功callback
|
||||
* @Param 失败callback
|
||||
* @Param 需要说出的信息
|
||||
*/
|
||||
xunfeiListenSpeaking.startSpeak(success, error, message);
|
||||
|
||||
// 停止说话
|
||||
xunfeiListenSpeaking.stopSpeak();
|
||||
|
||||
|
||||
// 暂停说话
|
||||
xunfeiListenSpeaking.pauseSpeaking();
|
||||
|
||||
// 恢复说话
|
||||
xunfeiListenSpeaking.resumeSpeaking();
|
||||
|
||||
|
||||
# 科大讯飞的语音听说读写的cordova插件
|
||||
|
||||
## 安装方法
|
||||
|
||||
APP_KEY参数值为您在科大讯飞申请的appid
|
||||
|
||||
运行cordova plugin add https://gitee.com/shuto/cordova-plugin-IFlyspeech-master.git --variable APP_KEY=${APP_KEY}
|
||||
|
||||
## 调用方法
|
||||
|
||||
|
||||
/** 开始录音 最大持续时间40秒
|
||||
* @Param 成功callback
|
||||
* @Param 失败callback
|
||||
* @Param 是否显示录音画面
|
||||
* @Param 是否显示标点
|
||||
*
|
||||
*/
|
||||
xunfeiListenSpeaking.startListen(success, error, isShowDialog, isShowPunc);
|
||||
|
||||
// 停止录音
|
||||
xunfeiListenSpeaking.stopListen();
|
||||
|
||||
/**
|
||||
* 开始说话
|
||||
* @Param 成功callback
|
||||
* @Param 失败callback
|
||||
* @Param 需要说出的信息
|
||||
*/
|
||||
xunfeiListenSpeaking.startSpeak(success, error, message);
|
||||
|
||||
// 停止说话
|
||||
xunfeiListenSpeaking.stopSpeak();
|
||||
|
||||
|
||||
// 暂停说话
|
||||
xunfeiListenSpeaking.pauseSpeaking();
|
||||
|
||||
// 恢复说话
|
||||
xunfeiListenSpeaking.resumeSpeaking();
|
||||
|
||||
|
||||
|
10
plugin.xml
10
plugin.xml
@ -3,6 +3,8 @@
|
||||
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<name>cordova-plugin-xunfeiListenSpeaking</name>
|
||||
<preference name="APP_KEY" />
|
||||
<preference name="CHANNEL" default="developer-default" />
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.0" />
|
||||
</engines>
|
||||
@ -65,7 +67,7 @@
|
||||
<source-file src="src/android/src/com/thomas/xunfeilistenspeaking/XunfeiDialogActivity.java" target-dir="src/com/thomas/xunfeilistenspeaking" />
|
||||
<!-- res -->
|
||||
<config-file target="res/values/strings.xml" parent="/resources">
|
||||
<string name="app_id">5aace5bb</string>
|
||||
<string name="app_id">$APP_KEY</string>
|
||||
<string name="xunfei_cancel_listen">取消语音</string>
|
||||
</config-file>
|
||||
</platform>
|
||||
@ -87,6 +89,7 @@
|
||||
|
||||
<header-file src="src/ios/CDVSpeech.h" />
|
||||
<source-file src="src/ios/CDVSpeech.m" />
|
||||
<resource-file src="src/ios/IFlySpeechConfig.plist" />
|
||||
|
||||
<framework src="AVFoundation.framework" />
|
||||
<framework src="AddressBook.framework" />
|
||||
@ -102,8 +105,9 @@
|
||||
<framework src="CoreTelephony.framework" />
|
||||
<framework src="CoreLocation.framework" />
|
||||
<framework src="Contacts.framework" />
|
||||
|
||||
<framework src="src/ios/iflyMSC.framework" custom="true" />
|
||||
<config-file target="*IFlySpeechConfig.plist" parent="AppKey">
|
||||
<string>$APP_KEY</string>
|
||||
</config-file>
|
||||
</platform>
|
||||
|
||||
</plugin>
|
||||
|
@ -16,8 +16,6 @@
|
||||
#define STR_RESULTS @"results"
|
||||
#define STR_PROGRESS @"progress"
|
||||
|
||||
// always replace the appid and the SDK with what you get from voicecloud.cn
|
||||
#define SPEECH_APP_ID @"5c32bdde"
|
||||
|
||||
|
||||
@interface CDVSpeech()
|
||||
@ -30,14 +28,25 @@
|
||||
- (void)login:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
self.callbackId = command.callbackId;
|
||||
|
||||
self.appId = SPEECH_APP_ID;
|
||||
if(self.appId == nil) {
|
||||
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"IFlySpeechConfig" ofType:@"plist"];
|
||||
if (plistPath == nil) {
|
||||
NSLog(@"error: IFlySpeechConfig.plist not found");
|
||||
assert(0);
|
||||
}
|
||||
self.appId = [plistData valueForKey:@"AppKey"];
|
||||
}
|
||||
|
||||
NSString *initString = [[NSString alloc] initWithFormat:@"appid=%@",self.appId];
|
||||
[IFlySpeechUtility createUtility:initString];
|
||||
|
||||
}
|
||||
|
||||
- (void) loadAppID{
|
||||
|
||||
NSMutableDictionary *plistData = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
|
||||
}
|
||||
|
||||
#pragma mark - 语音录入
|
||||
- (void)startListening:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
|
8
src/ios/IFlySpeechConfig.plist
Normal file
8
src/ios/IFlySpeechConfig.plist
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AppKey</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
Loading…
x
Reference in New Issue
Block a user