ai.api.android.AIService Java Examples

The following examples show how to use ai.api.android.AIService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From PersonalAiChatBot with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate ( savedInstanceState );
    setContentView ( R.layout.activity_main );
    resultTextView=(TextView) findViewById ( R.id.resultTextView );
    listenButton=(Button) findViewById ( R.id.listenButton);
    int permission = ContextCompat.checkSelfPermission ( this, Manifest.permission.RECORD_AUDIO );
    if (permission!= PackageManager.PERMISSION_GRANTED){
       
        makeRequest();
    }
    final ai.api.android.AIConfiguration config = new ai.api.android.AIConfiguration(
            "5676027c25554d4da3ae2e0238c07e38",
            ai.api.AIConfiguration.SupportedLanguages.English, ai.api.android.AIConfiguration.RecognitionEngine.System);


    aiService = AIService.getService(this, (ai.api.android.AIConfiguration) config );
    aiService.setListener(this);
}
 
Example #2
Source File: ChatBot.java    From SensorsAndAi with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate ( savedInstanceState );
    setContentView ( R.layout.activity_chat_bot );
    resultTextView=(TextView) findViewById ( R.id.resultTextView );
    listenButton=(Button) findViewById ( R.id.listenButton);
    int permission = ContextCompat.checkSelfPermission ( this, Manifest.permission.RECORD_AUDIO );
    if (permission!= PackageManager.PERMISSION_GRANTED){

        makeRequest();
    }
    final ai.api.android.AIConfiguration config = new ai.api.android.AIConfiguration(
            "5676027c25554d4da3ae2e0238c07e38",
            ai.api.AIConfiguration.SupportedLanguages.English, ai.api.android.AIConfiguration.RecognitionEngine.System);


    aiService = AIService.getService(this, (ai.api.android.AIConfiguration) config );
    aiService.setListener(this);
}
 
Example #3
Source File: MainActivity.java    From Krishi-Seva with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    listenButton = (Button) findViewById(R.id.listenButton);
    resultTextView = (TextView) findViewById(R.id.resultTextView);
    final AIConfiguration config = new AIConfiguration("1e03efe2dfdc4a37a3e21e5d1056a4ec",
            AIConfiguration.SupportedLanguages.English,
            AIConfiguration.RecognitionEngine.System);

    int permission = ContextCompat.checkSelfPermission(this,
            Manifest.permission.RECORD_AUDIO);

    if (permission != PackageManager.PERMISSION_GRANTED) {
        Log.i(TAG, "Permission to record denied");
        makeRequest();
    }
    aiService = AIService.getService(this, config);
    aiService.setListener(this);
}
 
Example #4
Source File: AIServiceSampleActivity.java    From dialogflow-android-client with Apache License 2.0 5 votes vote down vote up
private void initService(final LanguageConfig selectedLanguage) {
    final AIConfiguration.SupportedLanguages lang = AIConfiguration.SupportedLanguages.fromLanguageTag(selectedLanguage.getLanguageCode());
    final AIConfiguration config = new AIConfiguration(selectedLanguage.getAccessToken(),
            lang,
            AIConfiguration.RecognitionEngine.System);

    if (aiService != null) {
        aiService.pause();
    }

    aiService = AIService.getService(this, config);
    aiService.setListener(this);
}
 
Example #5
Source File: AIButton.java    From dialogflow-android-client with Apache License 2.0 5 votes vote down vote up
public void initialize(final AIConfiguration config) {
    aiService = AIService.getService(getContext(), config);
    aiService.setListener(this);

    if (aiService instanceof GoogleRecognitionServiceImpl) {
        ((GoogleRecognitionServiceImpl) aiService).setPartialResultsListener(new PartialResultsListener() {
            @Override
            public void onPartialResults(final List<String> partialResults) {
                if (partialResultsListener != null) {
                    partialResultsListener.onPartialResults(partialResults);
                }
            }
        });
    }
}
 
Example #6
Source File: AIButton.java    From dialogflow-android-client with Apache License 2.0 2 votes vote down vote up
/**
 * Get AIService object for making different data requests
 * @return
 */
public AIService getAIService() {
    return aiService;
}
 
Example #7
Source File: AIDialog.java    From dialogflow-android-client with Apache License 2.0 2 votes vote down vote up
/**
 * Get AIService object for making different data requests
 * @return
 */
public AIService getAIService() {
    return aiButton.getAIService();
}