科大讯飞相关的库 implementation ‘me.luzhuo.java.android:lib_kedaxunfei:1.0.0-SNAPSHOT’
1. MSC (语音听写)
初始化
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
MSCManager.init(this, "5ef8a0eb");
}
}
final StringBuffer sb = new StringBuffer();
final MSCManager manager = MSCManager.instance(this);
manager.setMSCLintener(new MSCLinstener() {
@Override
public void start() {
sb.append("请开始你的表演!");
content_tv.setText(sb);
}
@Override
public void stop() {
sb.append("已停止你的表演!");
content_tv.setText(sb);
}
@Override
public void content(String content) {
sb.append(content);
content_tv.setText(sb);
}
@Override
public void error(String errMessage) {
sb.append(errMessage);
content_tv.setText(sb);
}
});
按住与松开
TextView anzhu = findViewById(R.id.anzhu);
anzhu.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
manager.start();
// Toast.makeText(MainActivity.this, "老子按下了", Toast.LENGTH_SHORT).show();
} else if (event.getAction() == MotionEvent.ACTION_UP) {
manager.stop();
//Toast.makeText(MainActivity.this, "老子松开了", Toast.LENGTH_SHORT).show();
}
return true;
}
});