当前位置: 首页>>代码示例>>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;未经允许,请勿转载。