Installation
From the scratch
We provide a sample code that demonstrates how to integrate the SDK into your Android app.
Check out the example app and test how it works.
Integrate into existing project
- Unzip the downloaded file and copy the
sori-sdk.aar
file to thelibs
folder of your Android project. - Also copy the
audio.pack
file to theassets/audiopack/
folder of your Android project. - Add paths for audio pack file if needed:
Gradle Settings
For Android, you need to add the following settings.gradle
file in project root:
// ... omit ...
dependencyResolutionManagement {
repositories {
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
}
}
SORI SDK uses CWAC-Provider for read audio pack file as a stream.
And add the following to your app's app/build.gradle
file:
// ...
android {
// ...
// add assets directory for store Audio pack file
sourceSets {
main {
assets.srcDirs += ['assets']
}
}
}
dependencies {
// ...
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.guava:guava:23.3-android'
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
implementation 'com.commonsware.cwac:provider:0.5.3'
implementation files('libs/sori-sdk.aar')
}
Proguard Settings
If you are using Proguard, you need to add the following to your app's proguard-rules.pro
file:
# ...
-keep class com.iplateia.afplib.** { *; }
AndroidManifest.xml Settings
Add the following to your app's AndroidManifest.xml
file:
<manifest ...>
<!-- required android permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- Only required after Android 33 tiramisu -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- required sori permissions -->
<permission
android:name="${packageName}.permission.SORI.DETECT"
android:protectionLevel="signature" />
<uses-permission android:name="${packageName}.permission.SORI.DETECT" />
<permission
android:name="${packageName}.permission.SORI.BIND"
android:protectionLevel="signature" />
<uses-permission android:name="${packageName}.permission.SORI.BIND" />
<permission
android:name="${packageName}.permission.SORI.BROADCAST"
android:protectionLevel="signature" />
<uses-permission android:name="${packageName}.permission.SORI.BROADCAST" />
<application ...>
<!-- providers -->
<provider
android:name="com.commonsware.cwac.provider.StreamProvider"
android:authorities="${packageName}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${packageName}.cacheprovider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/cachepaths"
tools:replace="android:resource" />
</provider>
<!-- internal audio recognition service -->
<service
android:name="com.iplateia.afplib.DetectorService"
android:exported="false"
android:permission="${packageName}.permission.SORI.DETECT"
android:process=":remote" />
<!-- foreground service for audio recognition unless the app is not in the foreground -->
<service
android:name="${packageName}.RecognitionService"
android:enabled="true"
android:exported="false" />
</application>
</manifest>
Ok, now you are ready to use the SDK. Next step is to Implementation.