Chạy mã mẫu
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.
Đến đây, bạn có thể chạy mẫu và tạo truy vấn.
Trong lệnh sau:
Thay thế my-dev-project
bằng
mã dự án Google Cloud Platform cho dự án Actions Console mà bạn
đã tạo. Cách tìm mã dự án trong Actions Console:
chọn dự án, nhấp vào biểu tượng bánh răng và chọn Cài đặt dự án.
Thay thế my-model
bằng tên của mô hình mà bạn muốn
đã tạo trong bước trước đó.
googlesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model
Nhấn phím Enter và thử một số truy vấn sau:
- Tôi là ai?
- Bây giờ là mấy giờ?
- Thời tiết ở San Francisco như thế nào?
Nếu Trợ lý không phản hồi, hãy làm theo hướng dẫn khắc phục sự cố.
Để thay đổi ngôn ngữ cho Trợ lý Google hoặc bật tính năng kết quả cá nhân,
dùng ứng dụng Trợ lý Google.
Tìm mã phiên bản thiết bị
Trong lần đầu chạy mẫu, hệ thống sẽ tạo một phiên bản thiết bị cho
thiết bị cụ thể. Phiên bản thiết bị này sẽ được liên kết với mẫu thiết bị
mà bạn chỉ định để chạy mẫu. Bạn cũng có thể tự tạo thực thể
bằng cách sử dụng công cụ đăng ký.
Mẫu này sẽ lưu cả mã mô hình và mã thực thể. Nếu bạn chạy mẫu mà không cung cấp
những dữ liệu này làm đối số, thì mặc định hệ thống sẽ sử dụng các mã nhận dạng đã lưu.
Tìm mã phiên bản thiết bị trong dữ liệu đầu ra cho mẫu.
INFO:root:Connecting to embeddedassistant.googleapis.com
WARNING:root:Device config not found: [Errno 2] No such file or directory: '/home/pi/.config/googlesamples-assistant/device_config.json'
INFO:root:Registering device
INFO:root:Device registered: 0eea18ae-d17e-11e7-ac7a-b827ebb8010f # Device instance ID
Press Enter to send a new request...
Bước tiếp theo
Giờ đây, khi bạn đã kích hoạt Trợ lý Google trên thiết bị, đã đến lúc
mở rộng. Bạn có thể xem một số bước tiếp theo có thể thực hiện tại đây
hoặc tiếp tục tạo Hành động trên thiết bị.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eRun the provided command, replacing placeholders with your project and model IDs, to initiate a sample query.\u003c/p\u003e\n"],["\u003cp\u003eTest the setup with example queries like "Who am I?", "What time is it?", or weather-related questions.\u003c/p\u003e\n"],["\u003cp\u003eLocate the device instance ID within the sample's output for future use and potential troubleshooting.\u003c/p\u003e\n"],["\u003cp\u003eRefer to provided resources for troubleshooting, language settings, and next steps in extending device functionality.\u003c/p\u003e\n"]]],["To run the sample, replace placeholders in the provided command with your Google Cloud project ID and model name. Execute the command and try example queries. If no response, consult troubleshooting. The first run generates a unique device instance ID, displayed in the output, and saves it for future use. The command can be run without arguments if the ID was saved. You can change the language or add personal settings through the Google Assistant app. Further steps like extending or adding device actions are possible.\n"],null,["# Run the Sample Code\n\nAt this point, you are ready to run the sample and make a query.\n\nIn the following command:\n\n- Replace \u003cvar translate=\"no\"\u003emy-dev-project\u003c/var\u003e with\n the Google Cloud Platform project ID for the Actions Console project you\n created. To find the project ID in the [Actions Console](https://console.actions.google.com/),\n select the project, click the gear icon, and select **Project settings**.\n\n- Replace \u003cvar translate=\"no\"\u003emy-model\u003c/var\u003e with the name of the model you\n created in the previous [step](/assistant/sdk/guides/service/python/embed/register-device).\n\n```\ngooglesamples-assistant-pushtotalk --project-id my-dev-project --device-model-id my-model\n```\n\nPress the Enter key and try some of the following queries:\n\n- *Who am I?*\n- *What time is it?*\n- *What is the weather in San Francisco?*\n\nIf the Assistant does not respond, follow the [troubleshooting instructions](/assistant/sdk/guides/service/troubleshooting).\n\nTo change the language for the Google Assistant or to enable personal results,\nuse the Google Assistant [app](/assistant/sdk/reference/assistant-app/assistant-settings).\n\nFind the device instance ID\n---------------------------\n\nWhen you run the sample the first time, it will generate a device instance for your\nparticular device. This device instance will be associated with the device model\nthat you specified to run the sample. You can also create the instance yourself\nusing the [registration tool](/assistant/sdk/reference/device-registration/device-tool#register-device).\n\nThe sample saves both model and instance IDs. If you run the sample without providing\nthese as arguments, it will default to using the saved IDs.\n\nFind the device instance ID in the output for the sample. \n\n INFO:root:Connecting to embeddedassistant.googleapis.com\n WARNING:root:Device config not found: [Errno 2] No such file or directory: '/home/pi/.config/googlesamples-assistant/device_config.json'\n INFO:root:Registering device\n INFO:root:Device registered: 0eea18ae-d17e-11e7-ac7a-b827ebb8010f # Device instance ID\n Press Enter to send a new request...\n\nNext step\n---------\n\nNow that you have the Google Assistant working on your device, it is time to\nextend it. You can take a look at some possible next steps [here](/assistant/sdk/guides/service/python/embed/next-steps)\nor continue on to creating [Device Actions](/assistant/sdk/guides/service/python/extend/install-hardware)."]]