Android 讯飞开放平台 语音听写
一https://www.xfyun.cn/ 讯飞开放平台 下载语音听写SDK
二.导入 语音听写demo
2.1.speechDemo 导jar包
2.2.AndroidManifest.xml Manifest中添加权限
1 2 3 4 5 6 7 8 9 10 | <?xml version= "1.0" encoding= "utf-8" ?> <manifest xmlns:android= "http://schemas.android.com/apk/res/android" package = "com.iflytek.voicedemo" android:versionCode= "1" android:versionName= "2.0.1018.1013" > <uses-permission android:name= "android.permission.INTERNET" /> <uses-permission android:name= "android.permission.RECORD_AUDIO" /> <uses-permission android:name= "android.permission.CAMERA" /> <uses-permission android:name= "android.permission.READ_PHONE_STATE" /> |
2.3. build.gradle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | plugins { id 'com.android.application' } android { compileSdkVersion 30 buildToolsVersion "30.0.3" defaultConfig { applicationId "com.iflytek.voicedemo" minSdkVersion 22 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile( 'proguard-android-optimize.txt' ), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } sourceSets { main { jniLibs.srcDirs = [ 'libs' ] } } } dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'com.google.android.material:material:1.2.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.1' implementation files( 'libs\\Msc.jar' ) implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.4.0' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } |
2.4. gradle.properties
android.injected.testOnly=false
使用AS自动运行时会在app\build\outputs\apk\debug文件夹下自动生成测试APK:app-debug.apk,
用命令adb install app-debug.apk时报错:Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
解决办法:
1. 添加-t参数: 输入命令adb install -t app-debug.apk
2. 在gradle.properties(项目根目录或者gradle全局配置目录 ~/.gradle/)文件中添加:
android.injected.testOnly=false
产生原因:
Android Studio 3.0会在debug apk的manifest文件application标签里自动添加 android:testOnly="true"属性
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】