use of ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder in project K6nele by Kaljurand.
the class WebSocketRecognitionService2 method configure.
@Override
protected void configure(Intent recognizerIntent) throws IOException {
ChunkedWebRecSessionBuilder builder = new ChunkedWebRecSessionBuilder(this, recognizerIntent.getExtras(), null);
mUrl = "ws://localhost:82/duplex-speech-api/ws/speech" + getAudioRecorder().getWsArgs() + QueryUtils.getQueryParams(recognizerIntent, builder, "UTF-8");
configureHandler(false, false);
}
use of ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder in project K6nele by Kaljurand.
the class RecognizerIntentActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setUpActivity(R.layout.recognizer);
setUpExtras();
try {
mRecSessionBuilder = new ChunkedWebRecSessionBuilder(this, getExtras(), getCallingActivity());
} catch (MalformedURLException e) {
// The user has managed to store a malformed URL in the configuration.
handleResultError(RecognizerIntent.RESULT_CLIENT_ERROR, "", e);
}
mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
// For the change in the autostart-setting to take effect,
// the user must restart the app. This seems more natural.
mStartRecording = isAutoStart();
mTvPrompt = (TextView) findViewById(R.id.tvPrompt);
registerPrompt(mTvPrompt);
mBStartStop = (Button) findViewById(R.id.bStartStop);
mLlTranscribing = (LinearLayout) findViewById(R.id.llTranscribing);
mLlProgress = (LinearLayout) findViewById(R.id.llProgress);
mLlError = (LinearLayout) findViewById(R.id.llError);
mTvBytes = (TextView) findViewById(R.id.tvBytes);
mChronometer = (Chronometer) findViewById(R.id.chronometer);
mIvVolume = (ImageView) findViewById(R.id.ivVolume);
mIvWaveform = (ImageView) findViewById(R.id.ivWaveform);
mTvChunks = (TextView) findViewById(R.id.tvChunks);
mTvErrorMessage = (TextView) findViewById(R.id.tvErrorMessage);
mRes = getResources();
mVolumeLevels = new ArrayList<>();
mVolumeLevels.add(mRes.getDrawable(R.drawable.speak_now_level0));
mVolumeLevels.add(mRes.getDrawable(R.drawable.speak_now_level1));
mVolumeLevels.add(mRes.getDrawable(R.drawable.speak_now_level2));
mVolumeLevels.add(mRes.getDrawable(R.drawable.speak_now_level3));
mVolumeLevels.add(mRes.getDrawable(R.drawable.speak_now_level4));
mVolumeLevels.add(mRes.getDrawable(R.drawable.speak_now_level5));
mVolumeLevels.add(mRes.getDrawable(R.drawable.speak_now_level6));
mAudioCue = new AudioCue(this);
}
use of ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder in project K6nele by Kaljurand.
the class HttpRecognitionService method configure.
@Override
protected void configure(Intent recognizerIntent) throws IOException {
ChunkedWebRecSessionBuilder mRecSessionBuilder = new ChunkedWebRecSessionBuilder(this, getExtras(), null);
mRecSessionBuilder.setContentType(getEncoderType(), getSampleRate());
if (Log.DEBUG)
Log.i(mRecSessionBuilder.toStringArrayList());
mRecSession = mRecSessionBuilder.build();
try {
mRecSession.create();
} catch (IOException e) {
onError(SpeechRecognizer.ERROR_NETWORK);
} catch (NotAvailableException e) {
// This cannot happen in the current net-speech-api?
onError(SpeechRecognizer.ERROR_SERVER);
}
}
use of ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder in project K6nele by Kaljurand.
the class WebSocketRecognitionService method configure.
@RequiresPermission(RECORD_AUDIO)
@Override
protected void configure(Intent recognizerIntent) throws IOException {
Bundle bundle = getExtras();
ChunkedWebRecSessionBuilder builder = new ChunkedWebRecSessionBuilder(this, bundle, null);
List<Pair<String, String>> list = QueryUtils.getQueryParams(recognizerIntent, builder);
list.add(new Pair<>("content-type", getAudioRecorder().getContentType()));
mUrl = QueryUtils.combine(getServerUrl(R.string.keyWsServer, R.string.defaultWsServer), QueryUtils.encodeKeyValuePairs(list, "UTF-8"));
// Extra overrides the preferences
boolean isUnlimitedDuration;
Object obj = bundle.get(Extras.EXTRA_UNLIMITED_DURATION);
if (obj == null) {
obj = bundle.get(Extras.EXTRA_DICTATION_MODE);
}
if (obj == null) {
isUnlimitedDuration = !PreferenceUtils.getPrefBoolean(getSharedPreferences(), getResources(), R.string.keyWsAutoStopAfterPause, R.bool.defaultWsAutoStopAfterPause);
} else {
isUnlimitedDuration = (Boolean) obj;
}
configureHandler(isUnlimitedDuration, bundle.getBoolean(RecognizerIntent.EXTRA_PARTIAL_RESULTS, false));
}
Aggregations