fix(voice): 修正火山 V3 流式端点鉴权头(真火山联调验通协议格式)
联调发现 Authorization: Bearer 不被 openspeech V3 二进制流端点接受。改用官方规范头: - X-Api-App-Key: 固定常量 PlgvMymc7f3tQnJ6(所有客户端同值,缺它 400 "app key not found") - X-Api-Access-Key: 新版 API Key(账号鉴权) - X-Api-App-ID: 账号 App ID(解析资源授权,缺它 401 "grant not found") - X-Api-Resource-Id / X-Api-Connect-Id 改动:Config 加 AppID 字段;frame.go setVolcAuthHeaders 统一挂头 + handshakeDetail 榨取握手失败的 HTTP 状态/logid/body(联调可诊断);asr/tts 共用;voicecheck 加握手探针 分别验 ASR/TTS 端点;voiceconfig/voicecheck 读 VOLC_APP_ID。 现状:协议格式已被真火山接受(过了 400 格式错,进到账号/资源授权查询)。剩 App ID + 资源开通确认(账号侧,联调补)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
func main() {
|
||||
cfg := voice.Config{
|
||||
APIKey: os.Getenv("VOLC_API_KEY"),
|
||||
AppID: os.Getenv("VOLC_APP_ID"),
|
||||
ASRResourceID: os.Getenv("VOLC_ASR_RESOURCE_ID"),
|
||||
TTSResourceID: os.Getenv("VOLC_TTS_RESOURCE_ID"),
|
||||
TTSVoiceType: os.Getenv("VOLC_TTS_VOICE"),
|
||||
@@ -41,6 +42,16 @@ func main() {
|
||||
}
|
||||
fmt.Printf("配置:ASR-resource=%q TTS-resource=%q 音色=%q\n", cfg.ASRResourceID, cfg.TTSResourceID, cfg.TTSVoiceType)
|
||||
|
||||
// ---- 0. 握手探针:分别验 ASR / TTS 端点能否连上(区分"鉴权方案错"还是"某个 resource-id 错")----
|
||||
if cfg.ASREnabled() {
|
||||
if asr, err := voice.StartASR(context.Background(), cfg, "probe"); err != nil {
|
||||
fmt.Printf("[探针] ASR 握手 ❌ %v\n", err)
|
||||
} else {
|
||||
fmt.Println("[探针] ASR 握手 ✅(鉴权方案 + ASR resource-id 有效)")
|
||||
asr.Close()
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 1. TTS:合成 → 收音频 ----
|
||||
fmt.Printf("\n[TTS] 合成:%q\n", text)
|
||||
pcm24k, err := runTTS(cfg, text)
|
||||
|
||||
@@ -32,6 +32,7 @@ func main() {
|
||||
}
|
||||
cfg := voice.Config{
|
||||
APIKey: os.Getenv("VOLC_API_KEY"),
|
||||
AppID: os.Getenv("VOLC_APP_ID"),
|
||||
ASRResourceID: os.Getenv("VOLC_ASR_RESOURCE_ID"),
|
||||
TTSResourceID: os.Getenv("VOLC_TTS_RESOURCE_ID"),
|
||||
TTSVoiceType: os.Getenv("VOLC_TTS_VOICE"),
|
||||
|
||||
Reference in New Issue
Block a user