Search in sources :

Example 1 with ChunkedWebRecSessionBuilder

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);
}
Also used : ChunkedWebRecSessionBuilder(ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder)

Example 2 with ChunkedWebRecSessionBuilder

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);
}
Also used : MalformedURLException(java.net.MalformedURLException) ChunkedWebRecSessionBuilder(ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder) AudioCue(ee.ioc.phon.android.speechutils.AudioCue)

Example 3 with ChunkedWebRecSessionBuilder

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);
    }
}
Also used : ChunkedWebRecSessionBuilder(ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder) IOException(java.io.IOException) NotAvailableException(ee.ioc.phon.android.recsession.NotAvailableException)

Example 4 with ChunkedWebRecSessionBuilder

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));
}
Also used : Bundle(android.os.Bundle) ChunkedWebRecSessionBuilder(ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder) Pair(android.util.Pair) RequiresPermission(androidx.annotation.RequiresPermission)

Aggregations

ChunkedWebRecSessionBuilder (ee.ioc.phon.android.speak.ChunkedWebRecSessionBuilder)4 Bundle (android.os.Bundle)1 Pair (android.util.Pair)1 RequiresPermission (androidx.annotation.RequiresPermission)1 NotAvailableException (ee.ioc.phon.android.recsession.NotAvailableException)1 AudioCue (ee.ioc.phon.android.speechutils.AudioCue)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1