一款,整合百度翻译api跟有道翻译api的翻译君
程序员文章站
2023-12-24 21:28:03
...
项目介绍:
Translation-Voice 一个整合百度翻译(支持多种语言)
跟科大讯飞的口语翻译app
添加的依赖
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();
}
}