stc-speechkit-android
Use the STC SpeechKit library to integrate speech recognition, text-to-speech and diarization.
System Requirements
- Minimum required Android platform version: 4.1 (API Level 16)
- Internet Connection
Before you get started
- Review the Documentation for the library API
- Register on the website and get credentials
Integration
Download the project and compile from the sources or use Gradle:
Add the dependency to your project's top-level build.gradle:
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
}
Then add the plugin to your app-level build.gradle:
dependencies {
...
implementation 'com.speechpro.android:stcspeechkit:0.8.4'
}
How to use STC SpeechKit
Initialization STCSpeechKit
STCSpeechKit.init(activity!!.applicationContext, login, password, domainId.toInt())
Enabling logging
STCSpeechKit.setLogging(true)
WebSocketRecognizer
webSocketRecognizer = WebSocketRecognizer.Builder(this)
.build()
webSocketRecognizer.startRecording()
webSocketRecognizer.stopRecording()
override fun onRecognizerTextMessage(result: String) {
//intermediate result
}
override fun onRecognizerTextResult(result: String) {
//final result
}
RestApiRecognizer
restApiRecognizer = RestApiRecognizer.Builder(this)
.build()
restApiRecognizer.startRecording()
restApiRecognizer.stopRecording()
override fun onRecognizerTextMessage(result: String) {
//intermediate result
}
override fun onRecognizerTextResult(result: String) {
//final result
}
WebSocketSynthesizer
webSocketSynthesizer = WebSocketSynthesizer.Builder(this)
.language(Language.Russian)
.speaker("Alexander")
.build()
webSocketSynthesizer.synthesize("Тестовый синтез")
override fun onSynthesizerResult(byteArray: ByteArray) {
//PCM
}
RestApiSynthesizer
restApiSynthesizer = RestApiSynthesizer.Builder(this)
.language(Language.Russian)
.speaker("Alexander")
.build()
restApiSynthesizer.synthesize("Тестовый синтез")
override fun onSynthesizerResult(byteArray: ByteArray) {
//WAV
}
RestApiDiarization
diarization = RestApiDiarization.Builder(this)
.build()
diarization.startRecording()
diarization.stopRecording()
override fun onDiarizationResult(result: Data) {
//result
}
License
Copyright (c) 2019 STC. Licensed under the FreeBSD License.