當前位置: 首頁>>代碼示例>>Java>>正文


Java APIConfiguration類代碼示例

本文整理匯總了Java中ai.olami.cloudService.APIConfiguration的典型用法代碼示例。如果您正苦於以下問題:Java APIConfiguration類的具體用法?Java APIConfiguration怎麽用?Java APIConfiguration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


APIConfiguration類屬於ai.olami.cloudService包,在下文中一共展示了APIConfiguration類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create example list
    ListView ActivityListView = (ListView) findViewById(R.id.listview);
    String[] ActivityList = {
            getString(R.string.SpeechInput),
            getString(R.string.TextInput) +" - "+ getString(R.string.WordSegmentation),
            getString(R.string.TextInput) +" - "+ getString(R.string.NLIAnalysis),
    };
    ArrayAdapter adapter = new ArrayAdapter(this,
            android.R.layout.simple_list_item_1,
            ActivityList);
    ActivityListView.setAdapter(adapter);
    ActivityListView.setOnItemClickListener(ActivityListCick);

    // load the default App-Key & App-Secret.
    String appKey = Config.getAppKey();
    String appSecret = Config.getAppSecret();
    if ((appKey.isEmpty() || appKey.startsWith("*"))
            || (appSecret.isEmpty() || appSecret.startsWith("*"))) {
        // If the developer doesn't change keys, pop up and the developer to input their keys.
        onCreateConfigurationDialog().show();
    }

    // Set default localization setting by the setting of system language.
    String systemLanguage = getSystemLanguage();
    if (systemLanguage.equals("zh-TW")) {
        Config.setLocalizeOption(APIConfiguration.LOCALIZE_OPTION_TRADITIONAL_CHINESE);
    } else {
        Config.setLocalizeOption(APIConfiguration.LOCALIZE_OPTION_SIMPLIFIED_CHINESE);
    }
}
 
開發者ID:olami-developers,項目名稱:olami-android-client-sdk,代碼行數:36,代碼來源:MainActivity.java

示例2: onOptionsItemSelected

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    // Manually switch the localization setting.
    if (id == R.id.setting_changeCN) {
        Config.setLocalizeOption(APIConfiguration.LOCALIZE_OPTION_SIMPLIFIED_CHINESE);
        switchLanguage(this, "china");
    } else if (id == R.id.setting_changeTW){
        Config.setLocalizeOption(APIConfiguration.LOCALIZE_OPTION_TRADITIONAL_CHINESE);
        switchLanguage(this, "taiwan");
    }

    return super.onOptionsItemSelected(item);
}
 
開發者ID:olami-developers,項目名稱:olami-android-client-sdk,代碼行數:16,代碼來源:MainActivity.java

示例3: onCreate

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_text_input_word_segmentation);

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

    textInputSubmitButton = (Button) findViewById(R.id.textSubmitButton);
    textInputSubmitButton.setOnClickListener(new textInputSubmitButtonListener());
    textInputEdit = (EditText) findViewById(R.id.textInputEditText);
    textInputResponse = (TextView) findViewById(R.id.textInputSegAPIResponse);
    textInputResponse.setMovementMethod(ScrollingMovementMethod.getInstance());

    mJsonDump = GsonFactory.getDebugGson(false);

    // * Step 1: Configure your key and localize option.
    APIConfiguration config = new APIConfiguration(
            Config.getAppKey(), Config.getAppSecret(), Config.getLocalizeOption());

    // * Step 2: Create the text recognizer.
    mRecognizer = new TextRecognizer(config);
    mRecognizer.setSdkType("android");

    // * Optional steps: Setup some other configurations.
    mRecognizer.setEndUserIdentifier("Someone");
    mRecognizer.setTimeout(10000);

}
 
開發者ID:olami-developers,項目名稱:olami-android-client-sdk,代碼行數:30,代碼來源:TextInputWordSegmentationActivity.java

示例4: onCreate

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_text_input_nli_analysis);

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

    textInputSubmitButton = (Button) findViewById(R.id.textSubmitButton);
    textInputSubmitButton.setOnClickListener(new textInputSubmitButtonListener());
    textInputEdit = (EditText) findViewById(R.id.textInputEditText);
    textInputResponse = (TextView) findViewById(R.id.textInputNLIAPIResponse);
    textInputResponse.setMovementMethod(ScrollingMovementMethod.getInstance());

    mJsonDump = GsonFactory.getDebugGson(false);

    // * Step 1: Configure your key and localize option.
    APIConfiguration config = new APIConfiguration(
            Config.getAppKey(), Config.getAppSecret(), Config.getLocalizeOption());

    // * Step 2: Create the text recognizer.
    mRecognizer = new TextRecognizer(config);
    mRecognizer.setSdkType("android");

    // * Optional steps: Setup some other configurations.
    mRecognizer.setEndUserIdentifier("Someone");
    mRecognizer.setTimeout(10000);

}
 
開發者ID:olami-developers,項目名稱:olami-android-client-sdk,代碼行數:30,代碼來源:TextInputNLIAnalysisActivity.java

示例5: SdkEntity

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
public SdkEntity(String appKey, String appSecret, String userId) {
	Util.d("new SdkEntity() start.  appKey:" + appKey + ", appSecret: " + appSecret + ", userId: " + userId);
	try {
		config = new APIConfiguration(appKey, appSecret, localizeOption);
		recoginzer = new SpeechRecognizer(config);
    	recoginzer.setEndUserIdentifier(userId);
    	recoginzer.setTimeout(10000);
    	recoginzer.setAudioType(audioType);
	} catch (Exception e) {
		Util.w("new SdkEntity() exception", e);
	}
	Util.d("new SdkEntity() done");
}
 
開發者ID:happycxz,項目名稱:silk2asr,代碼行數:14,代碼來源:SdkEntity.java

示例6: onResume

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
@Override
protected void onResume() {
    super.onResume();

    // Check if the user agrees to access the microphone
    boolean hasMicrophonePermission = checkApplicationPermissions(
            Manifest.permission.RECORD_AUDIO,
            REQUEST_MICROPHONE);

    if (hasMicrophonePermission) {
        // * Step 1: Configure your key and localize option.
        APIConfiguration config = new APIConfiguration(
                Config.getAppKey(), Config.getAppSecret(), Config.getLocalizeOption());

        // * Step 2: Create the microphone recording speech recognizer.
        //           ----------------------------------------------------------
        //           You should implement the IRecorderSpeechRecognizerListener
        //           to get all callbacks and assign the instance of your
        //           listener class into this recognizer.
        mRecognizer = RecorderSpeechRecognizer.create(new SpeechRecognizerListener(), config);

        // * Optional step: Setup the recognize result type of your request.
        //                  The default setting is RECOGNIZE_RESULT_TYPE_STT for Speech-To-Text.
        mRecognizer.setRecognizeResultType(RecorderSpeechRecognizer.RECOGNIZE_RESULT_TYPE_ALL);

        // * Other optional steps: Setup some other configurations.
        //                         You can use default settings without bellow steps.
        mRecognizer.setEndUserIdentifier("Someone");
        mRecognizer.setApiRequestTimeout(3000);

        // * Advanced setting example.
        //   These are also optional steps, so you can skip these
        //   (or any one of these) to use default setting(s).
        // ------------------------------------------------------------------
        // * You can set the length of end time of the VAD in milliseconds
        //   to stop voice recording automatically.
        mRecognizer.setLengthOfVADEnd(3000);
        // * You can set the frequency in milliseconds of the recognition
        //   result query, then the recognizer client will query the result
        //   once every milliseconds you set.
        mRecognizer.setResultQueryFrequency(300);
        // * You can set audio length in milliseconds to upload, then
        //   the recognizer client will upload parts of audio once every
        //   milliseconds you set.
        mRecognizer.setSpeechUploadLength(300);
        // ------------------------------------------------------------------

        // Initialize volume bar of the input audio.
        voiceVolumeChangeHandler(0);

        if (mRecognizer.isAutoStopRecordingEnabled()) {
            autoStopSwitchChangeHandler(true);
        } else {
            autoStopSwitchChangeHandler(false);
        }
    }
}
 
開發者ID:olami-developers,項目名稱:olami-android-client-sdk,代碼行數:58,代碼來源:SpeechInputActivity.java

示例7: main

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
	if (args.length == 3) {
		initByInputArgs(args);
	} else if (args.length > 0) {
		printUsageAndExit();
	}
	
	// * Step 1: Configure your key and localize option.
	APIConfiguration config = new APIConfiguration(appKey, appSecret, localizeOption);
	
	// * Step 2: Create the text recognizer.
	TextRecognizer recoginzer = new TextRecognizer(config);
	
	System.out.format("\nTell me your name: ");
	Scanner reader = new Scanner(System.in);
	
	boolean fristTalk = true;		
	while (reader.hasNext()) {
		if (fristTalk) {
			String userName = reader.nextLine();
			if (userName.isEmpty()) {
				userName = " YOU ";
			}
			// Setup end user information.
			recoginzer.setEndUserIdentifier(userName);
			
			fristTalk = false;
			System.out.format("\nHi! %s\n", userName);
			System.out.format("\nType to say something or 'bye' to exit:\n");
		}
		
		String whatUserSays = reader.nextLine();
		if (whatUserSays.toLowerCase().equals("bye")) {
			System.out.format("\n[ OLAMI Robot ] Says: Bye!\n\n");
			reader.close();
			break;
		} else {
			System.out.format("\n[ %s ] Says: %s\n",
					recoginzer.getEndUserIdentifier(),
					whatUserSays);
		}

		// Create async task to request OLAMI API.
		CompletableFuture.supplyAsync(() -> {
			// Send text to the recognizer.
			try {
				return recoginzer.requestNLI(whatUserSays);
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}).whenComplete((response, exception) -> {
			// Get results to see the conversation reply.
			if (response.ok() && response.hasData()) {
				NLIResult[] nliResults = response.getData().getNLIResults();
				// Get the reply content.
				if (nliResults[0].hasDescObject()) {
					String reply = nliResults[0].getDescObject().getReplyAnswer();
					if (reply.isEmpty()) {
						System.out.format("\n[ OLAMI Robot ] Says: ...\n");
					} else {
						// Show the reply.
						System.out.format(
								"\n[ OLAMI Robot ] Says: %s", reply);
						// Show IDS data.
						if (nliResults[0].isFromIDS() 
								&& nliResults[0].hasDataObjects()) {
							System.out.println("\n");
							DumpIDSDataExample.dumpIDSData(nliResults[0]);
							System.out.println("\n");
						}
					}
					System.out.format(" (Say 'bye' to exit)\n");
				}
			}
		});			
	}
}
 
開發者ID:olami-developers,項目名稱:olami-java-client-sdk,代碼行數:78,代碼來源:AsyncTextChatbotExample.java

示例8: create

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
/**
 * Create a RecorderSpeechRecognizer instance.
 *
 * @param listener - The specified callback listener.
 * @param config - API configurations.
 * @return RecorderSpeechRecognizer instance.
 */
public static RecorderSpeechRecognizer create(
        IRecorderSpeechRecognizerListener listener,
        APIConfiguration config
) {
    return create(listener, new SpeechRecognizer(config));
}
 
開發者ID:olami-developers,項目名稱:olami-android-client-sdk,代碼行數:14,代碼來源:RecorderSpeechRecognizer.java

示例9: create

import ai.olami.cloudService.APIConfiguration; //導入依賴的package包/類
/**
 * Create a KeepRecordingSpeechRecognizer instance.
 *
 * @param recognizeListener - The specified callback listener.
 * @param config - API configurations.
 * @return KeepRecordingSpeechRecognizer instance.
 */
public static KeepRecordingSpeechRecognizer create(
        IKeepRecordingSpeechRecognizerListener recognizeListener,
        APIConfiguration config
) throws Exception{
    return create(recognizeListener, new SpeechRecognizer(config));
}
 
開發者ID:olami-developers,項目名稱:olami-android-client-sdk,代碼行數:14,代碼來源:KeepRecordingSpeechRecognizer.java


注:本文中的ai.olami.cloudService.APIConfiguration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。