5. Recording Function Interface
RecordOpImpl
Interface Name |
Parameters |
Return Value |
Description |
|---|---|---|---|
getRcspOp |
None
|
RcspOpImpl |
Get current RCSP operation implementation class |
getConnectedDevice |
None
|
BluetoothDevice |
Get current connected device |
getRecordState |
None
|
Get recording state |
|
addOnRecordStateCallback |
OnRecordStateCallback: Recording State Callback
|
Void |
Add recording state callback |
removeOnRecordStateCallback |
OnRecordStateCallback: Recording State Callback
|
Void |
Remove recording state callback |
setSupportSyncIatText |
boolean: Whether to support synchronous speech recognition text
|
Void |
(Currently ineffective) |
setSupportSyncNlpText |
boolean: Whether to support synchronous semantic recognition text
|
Void |
(Currently ineffective) |
setSupportPlayTTS |
boolean: Whether to play TTS
|
Void |
(Currently ineffective) |
startRecord |
device: Operation device
RecordParam: Recording Parameters
OnOperationCallback<Boolean>: Operation Result Callback
|
Void |
App side initiates start recording |
stopRecord |
device: Operation device
reason: Stop reason, 0: Normal, 1: Cancel
isIatText: Whether to synchronize speech recognition text
isNlpText: Whether to synchronize semantic recognition text
isTTS: Whether to synthesize and play tts
OnOperationCallback<Boolean>: Operation Result Callback
|
Void |
App side initiates stop recording |
release |
None
|
Void |
Release |
5.1. Recording Parameters
public class RecordParam {
//Audio data encoding format type: pcm, speex, opus
public static final int VOICE_TYPE_PCM = 0;
public static final int VOICE_TYPE_SPEEX = 1;
public static final int VOICE_TYPE_OPUS = 2;
//Audio data sampling rate type: 8k, 16k
public static final int SAMPLE_RATE_8K = 8;
public static final int SAMPLE_RATE_16K = 16;
//VAD method: dev, app
public static final int VAD_WAY_DEVICE = 0;
public static final int VAD_WAY_SDK = 1;
private final int voiceType;
private final int sampleRate;
private final int vadWay;
public RecordParam(int var1, int var2, int var3) {
this.voiceType = var1;
this.sampleRate = var2;
this.vadWay = var3;
}
//Audio data encoding format type: pcm, speex, opus
public int getVoiceType() {
return this.voiceType;
}
//Audio data sampling rate type: 8k, 16k
public int getSampleRate() {
return this.sampleRate;
}
//VAD method: dev, app
public int getVadWay() {
return this.vadWay;
}
public String toString() {
return "RecordParam{voiceType=" + this.voiceType + ", sampleRate=" + this.sampleRate + ", vadWay=" + this.vadWay + '}';
}
}
5.2. Recording State Callback
public interface OnRecordStateCallback {
/**
* Recording state change callback
* @param state Recording state
*/
void onStateChange(BluetoothDevice device, RecordState state);
}
5.3. Recording State
public class RecordState {
//Recording state - default
public static final int RECORD_STATE_IDLE = 0;
//Recording state - start recording
public static final int RECORD_STATE_START = 1;
//Recording state - recording
public static final int RECORD_STATE_WORKING = 2;
//Recording end - normal
public static final int REASON_NORMAL = 0;
//Recording end - cancel
public static final int REASON_STOP = 1;
//Current recording state
private int state = 0;
//Current recording parameters
private RecordParam recordParam;
//Current recording data block
private byte[] voiceDataBlock;
//Recording end - end reason
private int reason = 0;
private byte[] voiceData;
//Recording exception message
private String message;
//Whether to synchronize speech recognition text
private boolean isSyncIatText = false;
//Whether to synchronize semantic recognition text
private boolean isSyncNlpText = false;
//Whether to synthesize and play tts
private boolean isPlayTTS = false;
}