رفتن به مطلب
انجمن اندروید ایران | آموزش برنامه نویسی اندروید و موبایل
  • android.png.1fab383bc8500cd93127cebc65b1dcab.png

اضافه کردن قابلیت های صدا


پست های پیشنهاد شده

[align=left]Adding Voice Capabilities

[/align]

[align=left]Voice actions are an important part of the wearable experience. They let users carryout actions hands-free and quickly. Wear provides two types of voice actions:[/align]

[align=left]System-providedThese voice actions are task-based and are built into the Wear platform. You filter for them in the activity that you want to start when the voice action is spoken. Examples include "Take a note" or "Set an alarm".App-providedThese voice actions are app-based, and you declare them just like a launcher icon. Users say "Start " to use these voice actions and an activity that you specify starts.

Declare System-provided Voice Actions

 

     

         

         

     

 

Declare App-provided Voice Actions

 

     

         

         

     

 

Obtaining Free-form Speech Input

private static final int SPEECH_REQUEST_CODE = 0;

// Create an intent that can start the Speech Recognizer activity

private void displaySpeechRecognizer() {

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,

            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

// Start the activity, the intent will be populated with the speech text

    startActivityForResult(intent, SPEECH_REQUEST_CODE);

}

// This callback is invoked when the Speech Recognizer returns.

// This is where you process the intent and extract the speech text from the intent.

@Override

protected void onActivityResult(int requestCode, int resultCode,

        Intent data) {

    if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {

        List results = data.getStringArrayListExtra(

                RecognizerIntent.EXTRA_RESULTS);

        String spokenText = results.get(0);

        // Do something with spokenText

    }

    super.onActivityResult(requestCode, resultCode, data);

}

[/align]

لینک ارسال
به اشتراک گذاری در سایت های دیگر

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...