智能手表屏幕小、輸入難,語音交互是核心入口。接入成熟 NLP 平台 (如圖靈機器人) 可快速實現:天氣查詢、導航、備忘錄、閒聊等技能,無需自建 NLP 能力。
API Key。@RestController
@RequestMapping("/api/tuling")
public class TulingController {
@Value("${tuling.apiKey}")
private String apiKey;
@Value("${tuling.apiUrl:https://openapi.tuling123.com/openapi/api/v2}")
private String apiUrl;
@PostMapping("/chat")
public ResponseEntity chat(@RequestBody Map req) {
String userText = req.get("text");
String userId = req.get("userId"); // 設備/用戶唯一標識
// 構造圖靈 v2 請求體
Map payload = Map.of(
"reqType", 0, // 文本
"perception", Map.of("inputText", Map.of("text", userText)),
"userInfo", Map.of("apiKey", apiKey, "userId", userId)
);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity
圖靈 v2 支持 userId 維護會話上下文。手表端需持久化 userId (如 MAC 地址哈希),實現「剛才說的天氣,明天呢?」這類多輪交互。
「語音 + NLP 雲服務」是智能手表交互的標配架構。圖靈機器人提供開箱即用的中文 NLP 能力,配合 ASR/TTS,幾百行代碼即可構建可用的語音助手。核心難點在音頻鏈路穩定性、網絡弱網重試、多輪上下文管理。