Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Giới thiệu về tính năng tương tác bằng giọng nói
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
API Dịch vụ tương tác bằng giọng nói cung cấp một bản tóm tắt về nhiều ứng dụng điều khiển bằng giọng nói tiềm năng. Bạn có thể phát triển các phương thức triển khai theo các nguyên tắc được mô tả trong phần Phát triển ứng dụng.
Nội dung trong hướng dẫn tích hợp này mô tả cách tích hợp các ứng dụng này vào một hình ảnh hệ thống Android Automotive OS (AAOS) cụ thể.
Thuật ngữ
Các thuật ngữ sau đây được sử dụng trong hướng dẫn này:
- Dữ liệu hỗ trợ. Khi một phiên tương tác bằng giọng nói bắt đầu, hệ thống có thể chụp các chế độ xem và ảnh chụp màn hình, đồng thời truyền thông tin này đến phiên. Các ứng dụng có thể hiển thị thêm thông tin bằng cách triển khai
Activity#onProvideAssistData()
và Activity#onProvideAssistContent()
.
- Nhấn để nói (PTT). Nút điều khiển bằng giọng nói thực, thường nằm trong vô lăng.
- RecognitionService (RS). Dịch vụ nhận dạng giọng nói mà các ứng dụng sử dụng thông qua API
SpeechRecognizer
. VIA phải bao gồm cả VoiceInteractionService
và RecognitionService
.
- Chế độ nhấn để nói (TTT). Nút điều khiển bằng giọng nói qua phần mềm, thường là một phần của giao diện người dùng hệ thống). Trong Android, tính năng này còn được gọi là Cử chỉ hỗ trợ.
VoiceInteractionService
. Dịch vụ hệ thống gọn nhẹ do nhà phát triển VIA triển khai. Dịch vụ đã chọn được liên kết từ dịch vụ hệ thống khi khởi động và luôn chạy.
- VoiceInteractionSession (VIS). Lớp này đóng gói logic nghiệp vụ tương tác với người dùng. Thành phần này chịu trách nhiệm hiển thị cho người dùng trạng thái của hoạt động tương tác bằng giọng nói, xử lý các yêu cầu của VoiceInteractor và nhận dữ liệu hỗ trợ và ảnh chụp màn hình.
- VoiceInteractionSessionService (VSS). Một dịch vụ, một phần của
VIA, chịu trách nhiệm xử lý phiên tương tác bằng giọng nói. Dịch vụ này được liên kết từ dịch vụ hệ thống của Android trong quá trình tương tác bằng giọng nói với người dùng. Tất cả logic nghiệp vụ của phiên này được triển khai trong lớp
VoiceSession
.
Dịch vụ này chỉ được đảm bảo duy trì hoạt động trong một phiên thoại của người dùng.
- Ứng dụng tương tác bằng giọng nói (VIA). Ứng dụng Android được thiết kế để đóng vai trò là một công cụ điều khiển bằng giọng nói (gọi là trợ lý). Bạn có thể xác định những ứng dụng này bằng cách đưa
VoiceInteractionService
vào tệp kê khai.
Mỗi lần, bạn chỉ có thể chọn một trong các ứng dụng này làm mặc định trong hệ thống.
Chỉ ứng dụng mặc định mới được duy trì hoạt động (liên kết từ một dịch vụ hệ thống) và sẽ là trình nhận của các sự kiện Nhấn để nói (PTT) hoặc Nhấn để nói (TTT).
Trách nhiệm
Bảng này mô tả trách nhiệm của từng bên.
Nhà sản xuất ô tô (OEM) |
AOSP (Dự án nguồn mở Android) |
Nhà phát triển ứng dụng |
- Xây dựng một hệ thống thông tin giải trí tương thích với AAOS.
- Triển khai đầu vào và đầu ra âm thanh, bao gồm cả tính năng hỗ trợ phát hiện cụm từ kích hoạt DSP (không bắt buộc).
- Cấp quyền đặc quyền của hệ thống cho các dịch vụ tương tác bằng giọng nói.
- Tuân thủ các yêu cầu của
VoiceInteractionService liên quan đến quyền truy cập vào màn hình cài đặt của ứng dụng.
|
- Xác định và phát triển
VoiceInteractionService cũng như các API liên quan.
- Cung cấp tài liệu API, mã mẫu và tài liệu hỗ trợ khác cho nhà phát triển VIA.
- Cung cấp hướng dẫn về trải nghiệm người dùng kèm theo các yêu cầu và đề xuất.
|
- Triển khai API
VoiceInteractionService , API RecognitionService và API NotificationListenerService (xem nội dung mô tả chi tiết tại phần Phát triển ứng dụng).
- Cung cấp giao diện người dùng có thể tuỳ chỉnh mà nhà sản xuất thiết bị gốc (OEM) có thể điều chỉnh cho phù hợp với từng hệ thống thiết kế ô tô.
|
Yêu cầu về trải nghiệm người dùng
Nhà sản xuất thiết bị gốc (OEM) có trách nhiệm cao nhất trong việc mang đến trải nghiệm tốt cho người dùng.
Nhà sản xuất thiết bị gốc (OEM) phải đảm bảo rằng tất cả các dịch vụ tương tác bằng giọng nói được cài đặt sẵn đều đáp ứng các yêu cầu được mô tả trong phần Trợ lý được tải sẵn: Hướng dẫn về trải nghiệm người dùng.
Trải nghiệm cốt lõi của Trợ lý
Ứng dụng tương tác bằng giọng nói (VIA) dành cho ô tô thực hiện các thao tác sau:
- [BẮT BUỘC] Phản hồi các trình kích hoạt tương tác bằng giọng nói do hệ thống xử lý (PTT, TTT).
- [BẮT BUỘC] Hiển thị hình ảnh minh hoạ tiến trình của yêu cầu (ví dụ: đang nghe, đang xử lý và đã thực hiện).
- [PHẢI] Sử dụng giọng nói hoặc âm thanh để cho biết đã hiểu và hoàn tất yêu cầu của người dùng.
- [PHẢI] Làm trình nhận dạng lời nói cho các ứng dụng khác (xem API SpeechRecognizer).
- [NÊN] Phản hồi lệnh kích hoạt cụm từ kích hoạt.
- [CÓ THỂ] Hiển thị một hoạt động cài đặt để người dùng có thể định cấu hình VIA này (ví dụ: quyền, cấu hình cụm từ kích hoạt và đăng nhập).
- [MAY] Xử lý dữ liệu hỗ trợ (
Intent#ACTION_ASSIST
)
- [THÁNG 5] Hỗ trợ tương tác bằng giọng nói từ tính năng Khoá màn hình (màn hình khoá).
Thành phần
Nhìn chung, ứng dụng tương tác bằng giọng nói tương tác với các thành phần sau:

Hình 1. Đối tượng tương tác bằng giọng nói
Chi tiết:
VoiceInteractionManagerService
. Dịch vụ hệ thống này chịu trách nhiệm quản lý VIA mặc định và hiển thị chức năng của VIA đó cho phần còn lại của hệ thống.
RecognitionService
. Dịch vụ này hiển thị các tính năng nhận dạng lời nói cho các ứng dụng khác trong hệ thống.
SoundTrigger
. Triển khai tính năng quản lý cụm từ kích hoạt và tính năng này có sẵn cho các VIA thông qua AlwaysOnHotwordDetector.
MediaRecorder
. Cung cấp quyền truy cập vào đầu vào âm thanh cho cả tính năng phát hiện cụm từ kích hoạt (khi sử dụng CPU) và nhận dạng lời nói.
PhoneWindowManager
/CarInputService
. Các dịch vụ này chịu trách nhiệm (trong số những việc khác) xử lý các sự kiện chính, định tuyến PTT đến VIA thông qua VoiceInteractionManagerService
.
User
. Người dùng tương tác với VIA thông qua các Trình kích hoạt (PTT, TTT, Lệnh thoại kích hoạt) hoặc Giao diện người dùng của Voice Plate.
- CarService, Thông báo, Nội dung nghe nhìn, Điện thoại, ContactsProvider, v.v.
Các dịch vụ và ứng dụng mà VoiceInteractionSession sử dụng để thực hiện lệnh của người dùng.
Các khái niệm dành riêng cho ngành ô tô
AAOS khác với Android ở những khía cạnh sau:
- Ngoài các chức năng thông thường của Trợ lý, VIA AAOS có thể kiểm soát các chức năng của xe (ví dụ: hệ thống điều hòa không khí, ghế và đèn nội thất). Bạn có thể tích hợp các chức năng này bằng API CarPropertyManager (xem thêm tại phần Đọc thuộc tính của xe) miễn là nhà sản xuất thiết bị gốc (OEM) định cấu hình quyền truy cập chính xác như mô tả trong phần Danh sách cho phép quyền đặc quyền.
- Tính năng tuỳ chỉnh và tính nhất quán có liên quan nhiều hơn trong mảng Ô tô so với mọi kiểu dáng thiết bị khác. Hãy xem phần Tuỳ chỉnh để đọc thêm về cách triển khai các nguyên tắc này.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# About voice interaction\n\nThe Voice Interaction Service API provides an abstraction over different\npotential voice control apps. Implementations can be developed following the guidelines\ndescribed in\n[App development](/docs/automotive/voice/voice_interaction_guide/app_development).\nThe content in this integration guide describes how to integrate these apps into\na specific Android Automotive OS (AAOS) system image.\n\nTerminology\n-----------\n\nThese terms are used through this guide:\n\n- **Assist data.** When a voice interaction session is started, the system is able to capture views and screenshots, and pass this information to the session. Apps can expose additional information by implementing [Activity#onProvideAssistData()](https://developer.android.com/reference/android/app/Activity#onProvideAssistData(android.os.Bundle)) and [Activity#onProvideAssistContent()](https://developer.android.com/reference/android/app/Activity#onProvideAssistContent(android.app.assist.AssistContent)).\n- **[Push-to-talk (PTT)](https://developer.android.com/reference/android/service/voice/VoiceInteractionSession#SHOW_SOURCE_PUSH_TO_TALK)**. Physical voice control button, usually located in the steering wheel.\n- **RecognitionService (RS).** Voice recognition service used by apps through the [SpeechRecognizer](https://developer.android.com/reference/android/speech/SpeechRecognizer)`\n ` API. VIAs must include both the `VoiceInteractionService` *and* the `RecognitionService`.\n- **[Tap-to-talk (TTT)](https://developer.android.com/reference/android/service/voice/VoiceInteractionSession#SHOW_SOURCE_ASSIST_GESTURE)** . Software voice control button, usually included as part of the system UI). In Android this is also referred to as *Assist Gesture*.\n- **[VoiceInteractionService](https://developer.android.com/reference/android/service/voice/VoiceInteractionService)**. Lightweight system service implemented by the VIA developer. The selected service is bound from system service on boot, and is always running.\n- **VoiceInteractionSession (VIS).** This class encapsulates the user interaction business logic. It is responsible for presenting the user with status of the voice interaction, handling VoiceInteractor requests and receiving assist and screenshot data.\n- **VoiceInteractionSessionService (VSS).** A service, part of a VIA, responsible for handling a voice interaction session. This service is bound from Android's system service during a voice interaction with a user. All business logic of this session is implemented in the `VoiceSession` class. This service is only guaranteed to stay alive during a single user voice session.\n- **Voice Interaction App (VIA).** Android app designed to serve as a voice control (referred to as *assistant* ). These apps can be identified by including a `VoiceInteractionService` in their manifest. Only one of these apps can be selected as *default* at a time in the system. Only the default app will be maintained alive (bound from a system service), and will be the receiver of [Push-To-Talk (PTT)](https://developer.android.com/reference/android/service/voice/VoiceInteractionSession#SHOW_SOURCE_PUSH_TO_TALK) or [Tap-To-Talk (TTT)](https://developer.android.com/reference/android/service/voice/VoiceInteractionSession#SHOW_SOURCE_ASSIST_GESTURE) events.\n\nResponsibilities\n----------------\n\nThis table describes the responsibilities of each party.\n\n| Car Manufacturers (OEMs) | AOSP | App Developers |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - Build a [compatible](/compatibility/android-cdd) infotainment system with AAOS. - Implement audio input and output, optionally including DSP hotword detection support. - Grant system-privileged permissions for the voice interaction services. - Respect `VoiceInteractionService` requirements regarding access to app's settings screens. | - Define and evolve `VoiceInteractionService` and related APIs. - Provide API documentation, sample code and other support material to VIA developers. - Provide UX guidance with requirements and recommendations. | - Implement `VoiceInteractionService` API, RecognitionService API and NotificationListenerService API (see detailed description at [App development](/docs/automotive/voice/voice_interaction_guide/app_development)). - Provide a customizable UI that can be adjusted by OEMs to match each car design system. |\n\nUX requirements\n---------------\n\nOEMs have the ultimate responsibility of providing a good user experience to customers.\nOEMs must ensure that the all pre-installed voice interaction services fulfill the\nrequirements described in\n[Preloaded Assistants: UX Guidance](/static/docs/automotive/voice/voice_interaction_guide/preloaded-assistants_UX-guidelines.pdf).\n\nCore assistant experience\n-------------------------\n\nAn automotive Voice Interaction Application (VIA) performs the following actions:\n\n- \\[MUST\\] Respond to system-handled voice interaction triggers (PTT, TTT).\n- \\[MUST\\] Display a visual representation of their progress (for example, listening, processing, and fulfilling).\n- \\[MUST\\] Use voice or sounds to indicate understanding and completion of user requests.\n- \\[MUST\\] Serve as a speech recognizer for other apps (see the [SpeechRecognizer\n API](https://developer.android.com/reference/android/speech/SpeechRecognizer)).\n- \\[SHOULD\\] Respond to a hotword trigger.\n- \\[MAY\\] Display a settings activity where users can configure this VIA (for example, permissions, hotword configuration, and sign-in).\n- \\[MAY\\] Handle assist data ([Intent#ACTION_ASSIST](https://developer.android.com/reference/android/content/Intent#ACTION_ASSIST))\n- \\[MAY\\] Support voice interaction from Keyguard (lock screen).\n\nComponents\n----------\n\nAt a high level, a voice interaction app interacts with these actors:\n\n**Figure 1.** Voice interaction actors\n\nDetails:\n\n- `VoiceInteractionManagerService`. This system service is responsible for managing the default VIA, and exposing its functionality to the rest of the system.\n- `RecognitionService`. This service exposes speech recognition capabilities to other apps in the system.\n- `SoundTrigger`. Implements hotword management and it's available to VIAs through the AlwaysOnHotwordDetector.\n- `MediaRecorder`. Provides access to audio input for both hotword detection (when using CPU) and speech recognition.\n- `PhoneWindowManager`/`CarInputService`. These services are responsible (among other things) for handling key events, routing PTT to the VIA, by means of the `VoiceInteractionManagerService`.\n- `User`. The user interacts with a VIA by means of Triggers (PTT, TTT, Hotword) or the Voice Plate UI.\n- **CarService, Notifications, Media, Telephony, ContactsProvider, and so on.** Services and apps used by the VoiceInteractionSession to fulfill the user's commands.\n\nAutomotive-specific concepts\n----------------------------\n\nAAOS diverges from Android in the following aspects:\n\n- Besides normal Assistant functionalities, AAOS VIAs can control vehicle functions (for example, HVAC, seats, and interior lights). These functionalities can be integrated using the CarPropertyManager API (see more at [Read a\n vehicle property](/docs/automotive/voice/voice_interaction_guide/fulfilling_commands#vehicle-property)) provided OEMs configure access correctly as described in [Privileged permission allowlisting](/docs/core/permissions/perms-allowlist).\n- Customization and consistency are more relevant in Automotive than in any other form factor. See [Customization](/docs/automotive/voice/voice_interaction_guide/integration_flows#customization) to read more about implementing these guidelines."]]