基于百度翻译和有道翻译api的一款翻译Demo

基于百度翻译和有道翻译api的一款翻译Demo

Translation-Voice

一个整合百度翻译(支持多种语言)跟科大讯飞的口语翻译app

  
百度翻译界面科大讯飞语音识别跟语音合成界面
Screenshot_20180621-190257.png
Screenshot_20180621-190257.png
Screenshot_20180621-190304.png
Screenshot_20180621-190304.png
选择想要翻译的语言选择目标语言
Screenshot_20180621-190249.png
Screenshot_20180621-190249.png
Screenshot_20180621-190238.png
Screenshot_20180621-190238.png

添加的依赖

 implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:design:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation files('libs/Msc.jar')
    implementation files('libs/gson-2.8.1.jar')

登陆科大讯飞的官网注册账号下载新的SDK导入
并且修改MyApplication.java类的科大讯飞的参数即可使用

       SpeechUtility.createUtility(this, SpeechConstant.APPID + "=5ad97691");
       RecognitionManager.getSingleton().init(this,"5ad97691");
       SynthesisManager.getSingleton().init(this,"5ad97691");

登陆翻译开放平台
并申请成为开发者创建应用将你的AppID和password写入对应文件即可
别忘了重新导入jar包

IDActivity.class
               String appid = "你应用的AppID"
               String pw = "对应的password"

               File dir = getApplicationContext().getFilesDir();//查找这个应用下的所有文件所在的目录
               Log.d("文件夹:" , dir.getAbsolutePath());
               FileWriter writer;
               try {
                   writer = new FileWriter(dir.getAbsolutePath() + "/userinfo.txt");
                   writer.append(appid+","+pw+","+choose);
                   writer.close();
                   ToastUtil.showToast(IDActivity.this,"设置成功");
               } catch (IOException e) {
                   e.printStackTrace();
               }
          }
然后就可以愉快的的翻译跟语音了

如果觉得不错的话就点个start

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值