当前位置: 首页>>代码示例>>Java>>正文


Java APIResponse类代码示例

本文整理汇总了Java中ai.olami.cloudService.APIResponse的典型用法代码示例。如果您正苦于以下问题:Java APIResponse类的具体用法?Java APIResponse怎么用?Java APIResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


APIResponse类属于ai.olami.cloudService包,在下文中一共展示了APIResponse类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_speech_input);


    Intent intent = getIntent();
    Config.setLocalizeOption(intent.getIntExtra("LOCALIZE_OPTION", Config.getLocalizeOption()));

    recordButton = (Button) findViewById(R.id.recordButton);
    cancelButton = (Button) findViewById(R.id.cancelButton);
    voiceVolumeText = (TextView) findViewById(R.id.voiceVolume);
    voiceVolumeBar = (TextView) findViewById(R.id.voiceVolumeBar);
    STTText = (TextView) findViewById(R.id.STTText);
    APIResponseText = (TextView) findViewById(R.id.APIResponse);
    APIResponseText.setMovementMethod(ScrollingMovementMethod.getInstance());
    recognizeStatusText = (TextView) findViewById(R.id.recognizeStatus);
    recordStatusText = (TextView) findViewById(R.id.recordStatus);

    recordButton.setOnClickListener(new recordButtonListener());
    cancelButton.setOnClickListener(new cancelButtonListener());

    mAutoStopSwitch = (Switch) findViewById(R.id.autoStopSwitch);
    mAutoStopSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (mRecognizer != null) {
                mRecognizer.enableAutoStopRecording(isChecked);
            }
        }
    });
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:32,代码来源:SpeechInputActivity.java

示例2: onRecognizeResultChange

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
@Override
public void onRecognizeResultChange(APIResponse response) {

    // * Get recognition results.
    //   In this example, we only handle the speech-to-text result.
    SpeechResult sttResult = response.getData().getSpeechResult();

    if (sttResult.complete()) {

        // 'complete() == true' means returned text is final result.

        // --------------------------------------------------
        // * It also means you can get NLI/IDS results if included.
        //   So you can handle or process NLI/IDS results here ...
        //
        //   For example:
        //   NLIResult[] nliResults = response.getData().getNLIResults();
        //
        // * See also :
        //   - OLAMI Java Client SDK & Examples
        //   - ai.olami.nli.NLIResult.
        // --------------------------------------------------

        STTChangeHandler(sttResult.getResult());
        APIResponseChangeHandler(response.toString());

    } else {

        // Recognition has not yet been completed.
        // The text you get here is not a final result.

        if (sttResult.getStatus() == SpeechResult.STATUS_RECOGNIZE_OK) {
            STTChangeHandler(sttResult.getResult());
            APIResponseChangeHandler(response.toString());
        }

    }
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:39,代码来源:SpeechInputActivity.java

示例3: onClick

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
@Override
public void onClick (View v) {
    submitButtonChangeHandler(false, getString(R.string.RecognizeState_PROCESSING) +"...");
    new Thread(new Runnable() {
        @Override
        public void run() {
        try {
            // * Send text
            APIResponse response = mRecognizer.requestWordSegmentation(textInputEdit.getText().toString());
            // Check request status.
            if (response.ok() && response.hasData()) {

                String responseWordSeg = getString(R.string.Result) +" :\n";

                // * Get and sjpw the word segmentation results.
                String[] wordSegmentation = response.getData().getWordSegmentation();

                for (int i = 0; i < wordSegmentation.length; i++) {
                    responseWordSeg += wordSegmentation[i];
                    if (i != wordSegmentation.length - 1) {
                        responseWordSeg += ", ";
                    } else {
                        responseWordSeg += "\n\n";
                    }
                }

                responseWordSeg += getString(R.string.Response) +" :\n";
                responseWordSeg += mJsonDump.toJson(response);
                textInputAPIResponseChangeHandler(responseWordSeg);

                submitButtonChangeHandler(true, getString(R.string.Submit));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        }
    }).start();
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:39,代码来源:TextInputWordSegmentationActivity.java

示例4: doGetting

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
private void doGetting() throws Exception {
    while (!mCancel) {
        if (mGetting) {
            Thread.sleep(getFrequencyToGettingResult());
            APIResponse response = null;
            switch (getRecognizeResultType()) {
                case RECOGNIZE_RESULT_TYPE_ALL:
                    response = mRecognizer.requestRecognitionWithAll(mCookie, mNLIConfig);
                    break;
                case RECOGNIZE_RESULT_TYPE_STT:
                    response = mRecognizer.requestRecognition(mCookie);
                    break;
                case RECOGNIZE_RESULT_TYPE_NLI:
                    response = mRecognizer.requestRecognitionWithNLI(mCookie, mNLIConfig);
                    break;
            }
            if (response.ok() && response.hasData()) {
                SpeechResult sttResult = response.getData().getSpeechResult();
                if (mSendCallback) {
                    mListener.onRecognizeResultChange(response);
                }
                if (sttResult.complete()) {
                    changeRecognizeState(RecognizeState.COMPLETED);
                    break;
                }
            } else {
                recognizeResponseError(response);
            }
        }
    }
    changeRecognizeState(RecognizeState.STOPPED);
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:33,代码来源:RecorderSpeechRecognizer.java

示例5: doGetting

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
private void doGetting() throws Exception {
    while (!mCancel) {
        if (mGetting) {
            Thread.sleep(getFrequencyToGettingResult());
            APIResponse response = null;
            switch (getRecognizeResultType()) {
                case RECOGNIZE_RESULT_TYPE_ALL:
                    response = mRecognizer.requestRecognitionWithAll(mCookie, mNLIConfig);
                    break;
                case RECOGNIZE_RESULT_TYPE_STT:
                    response = mRecognizer.requestRecognition(mCookie);
                    break;
                case RECOGNIZE_RESULT_TYPE_NLI:
                    response = mRecognizer.requestRecognitionWithNLI(mCookie, mNLIConfig);
                    break;
            }
            if (response.ok() && response.hasData()) {
                SpeechResult sttResult = response.getData().getSpeechResult();
                if (mSendCallback) {
                    mCallback.onRecognizeResultChange(response);
                }
                if (sttResult.complete()) {
                    changeRecognizeState(RecognizeState.COMPLETED);
                    break;
                }
            } else {
                recognizeResponseError(response);
            }
        }
    }

    changeRecognizeState(RecognizeState.STOPPED);
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:34,代码来源:KeepRecordingSpeechRecognizer.java

示例6: main

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
if (args.length == 1) {
	APIResponse response = APIResponseBuilder.create(args[0]);
	if (response.hasData() && response.getData().hasNLIResults()) {
		DumpNLIResultsExample.dumpNLIResults(response.getData().getNLIResults());
	} else {
		System.out.println("Failed! Invalid Input String.");
	}
}
  }
 
开发者ID:olami-developers,项目名称:olami-java-client-sdk,代码行数:11,代码来源:DumpNLIResultsExampleExecution.java

示例7: onServerError

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
@Override
public void onServerError(APIResponse response) {
    Log.e(TAG, "Server error code: "+ response.getErrorCode()
            +", Error message: " + response.getErrorMessage());
    errorStateHandler("onServerError Code: "+ response.getErrorCode());
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:7,代码来源:SpeechInputActivity.java

示例8: onClick

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
@Override
public void onClick (View v) {
    submitButtonChangeHandler(false, getString(R.string.RecognizeState_PROCESSING) +"...");
    new Thread(new Runnable() {
        @Override
        public void run() {
        try {
            // * Send text to request NLI recognition.
            APIResponse response = mRecognizer.requestNLI(textInputEdit.getText().toString());
            //
            // You can also send text with NLIConfig to append "nli_config" JSON object.
            //
            // For Example,
            // try to replace 'requestNLI(inputText)' with the following sample code:
            // ===================================================================
            // NLIConfig nliConfig = new NLIConfig();
            // nliConfig.setSlotName("myslot");
            // APIResponse response = mRecognizer.requestNLI(textInputEdit.getText().toString(), nliConfig);
            // ===================================================================
            //

            // Check request status.
            if (response.ok() && response.hasData()) {
                // * Dump NLI results by JSON format.
                textInputAPIResponseChangeHandler(mJsonDump.toJson(response));
                // --------------------------------------------------
                // * You can also handle or process NLI/IDS results ...
                //
                //   For example:
                //   NLIResult[] nliResults = response.getData().getNLIResults();
                //
                // * See also :
                //   - OLAMI Java Client SDK & Examples
                //   - ai.olami.nli.NLIResult.
                // --------------------------------------------------

                submitButtonChangeHandler(true, getString(R.string.Submit));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        }
    }).start();
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:45,代码来源:TextInputNLIAnalysisActivity.java

示例9: recognizeResponseError

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
private void recognizeResponseError(APIResponse response) {
    mListener.onServerError(response);
    changeRecognizeState(RecognizeState.ERROR);
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:5,代码来源:RecorderSpeechRecognizer.java

示例10: recognizeResponseError

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
private void recognizeResponseError(APIResponse response) {
    mCallback.onServerError(response);
    changeRecognizeState(RecognizeState.ERROR);
}
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:5,代码来源:KeepRecordingSpeechRecognizer.java

示例11: onRecognizeResultChange

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
/**
 * Callback when the results of speech recognition changes.
 *
 * @param response - API response with all kinds of results.
 */
void onRecognizeResultChange(APIResponse response);
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:7,代码来源:IRecorderSpeechRecognizerListener.java

示例12: onServerError

import ai.olami.cloudService.APIResponse; //导入依赖的package包/类
/**
 * Callback when a server error occurs.
 *
 * @param response - API response with error message.
 */
void onServerError(APIResponse response);
 
开发者ID:olami-developers,项目名称:olami-android-client-sdk,代码行数:7,代码来源:IRecorderSpeechRecognizerListener.java


注:本文中的ai.olami.cloudService.APIResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。