科大讯飞相关的库 implementation ‘me.luzhuo.java.android:lib_kedaxunfei:1.0.0-SNAPSHOT’

1. MSC (语音听写)

初始化

  1. public class App extends Application {
  2. @Override
  3. public void onCreate() {
  4. super.onCreate();
  5. MSCManager.init(this, "5ef8a0eb");
  6. }
  7. }
  1. final StringBuffer sb = new StringBuffer();
  2. final MSCManager manager = MSCManager.instance(this);
  3. manager.setMSCLintener(new MSCLinstener() {
  4. @Override
  5. public void start() {
  6. sb.append("请开始你的表演!");
  7. content_tv.setText(sb);
  8. }
  9. @Override
  10. public void stop() {
  11. sb.append("已停止你的表演!");
  12. content_tv.setText(sb);
  13. }
  14. @Override
  15. public void content(String content) {
  16. sb.append(content);
  17. content_tv.setText(sb);
  18. }
  19. @Override
  20. public void error(String errMessage) {
  21. sb.append(errMessage);
  22. content_tv.setText(sb);
  23. }
  24. });

按住与松开

  1. TextView anzhu = findViewById(R.id.anzhu);
  2. anzhu.setOnTouchListener(new View.OnTouchListener() {
  3. @Override
  4. public boolean onTouch(View v, MotionEvent event) {
  5. if (event.getAction() == MotionEvent.ACTION_DOWN) {
  6. manager.start();
  7. // Toast.makeText(MainActivity.this, "老子按下了", Toast.LENGTH_SHORT).show();
  8. } else if (event.getAction() == MotionEvent.ACTION_UP) {
  9. manager.stop();
  10. //Toast.makeText(MainActivity.this, "老子松开了", Toast.LENGTH_SHORT).show();
  11. }
  12. return true;
  13. }
  14. });