docs(comments): 注释中文化 · internal/runtime/multimodal(21 文件,纯替换)
- 只翻注释/文档字符串,代码零变化:go/scanner 词法流比对 21 文件 token+字面量全等,增删行数 1:1(467/467) - 刻意保留非散文英文:JSON Schema description、工具 Description() 返回值、adapter prompt、API 路径与命令示例、环境变量名 - 逐行确认代码前缀未变,未触碰其他模块
This commit is contained in:
1 parent
b9e042d07d
commit
b0fbb8bc0d
21 files changed
+467
-467
No files matched your search
@@ -12,9 +12,9 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/config"
|
||||
)
|
||||
|
||||
// TestDashscopeLive verifies the real Alibaba Bailian STT + TTS end to end. It is
|
||||
// excluded from the default suite (build tag dashscope_live) so `go test ./...`
|
||||
// never hits the paid API. Run it explicitly with the key sourced from .env:
|
||||
// TestDashscopeLive 端到端验证真实的阿里百炼 STT + TTS。它
|
||||
// 被排除在默认测试集之外(构建标签 dashscope_live),使 `go test ./...`
|
||||
// 绝不触碰付费 API。用从 .env 取到的 key 显式运行:
|
||||
//
|
||||
// set -a; source .env; set +a
|
||||
// go test -tags dashscope_live -run TestDashscopeLive -v ./internal/runtime/multimodal/voice/
|
||||
@@ -25,7 +25,7 @@ func TestDashscopeLive(t *testing.T) {
|
||||
}
|
||||
cfg := config.VoiceConfig{DashscopeAPIKey: key}
|
||||
|
||||
// TTS: synthesize speech for a short line.
|
||||
// TTS:为一句短文本合成语音。
|
||||
tts := NewDashscopeTTS(cfg)
|
||||
audio, err := tts.TTS(context.Background(), "你好,我是昔涟")
|
||||
if err != nil {
|
||||
@@ -36,7 +36,7 @@ func TestDashscopeLive(t *testing.T) {
|
||||
t.Fatal("TTS returned empty audio")
|
||||
}
|
||||
|
||||
// STT closed loop: transcribe the synthesized speech back to text.
|
||||
// STT 闭环:把合成的语音转写回文字。
|
||||
stt := NewDashscopeSTT(cfg)
|
||||
text, err := stt.STT(context.Background(), Audio{Format: "wav", Data: audio.Data})
|
||||
if err != nil {
|
||||
@@ -44,7 +44,7 @@ func TestDashscopeLive(t *testing.T) {
|
||||
}
|
||||
t.Logf("STT (of TTS audio): text=%q", text)
|
||||
|
||||
// STT on a generated silence wav, to confirm the empty-audio path is accepted.
|
||||
// 对生成的静音 wav 做 STT,确认空音频路径可被接受。
|
||||
silence := silentWAVBytes(1, 16000)
|
||||
sttText, sttErr := stt.STT(context.Background(), Audio{Format: "wav", Data: silence})
|
||||
if sttErr != nil {
|
||||
@@ -53,8 +53,8 @@ func TestDashscopeLive(t *testing.T) {
|
||||
t.Logf("STT (silence): text=%q", sttText)
|
||||
}
|
||||
|
||||
// Exercise the degrading chain (the same object the gateway wires), proving it
|
||||
// returns real bytes/text rather than degrading to the silent terminal rung.
|
||||
// 走一遍降级链(网关接线的就是同一个对象),证明它
|
||||
// 返回真实的字节/文字,而不是降级到静默末端一级。
|
||||
ch := New(cfg)
|
||||
chTTS, chTTSErr := ch.TTS(context.Background(), "你好,我是昔涟")
|
||||
if chTTSErr != nil {
|
||||
@@ -74,21 +74,21 @@ func TestDashscopeLive(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// silentWAVBytes builds a mono 16-bit 16 kHz silence WAV of durS seconds.
|
||||
// silentWAVBytes 构造 durS 秒的单声道 16 位 16 kHz 静音 WAV。
|
||||
func silentWAVBytes(durS, sampleRate int) []byte {
|
||||
dataLen := durS * sampleRate * 2
|
||||
buf := &bytes.Buffer{}
|
||||
// RIFF header + fmt chunk + data chunk.
|
||||
// RIFF 头 + fmt 块 + data 块。
|
||||
buf.WriteString("RIFF")
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint32(36+dataLen))
|
||||
buf.WriteString("WAVEfmt ")
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint32(16))
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint16(1)) // PCM
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint16(1)) // mono
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint16(1)) // 单声道
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint32(sampleRate))
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint32(sampleRate*2))
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint16(2)) // block align
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint16(16)) // bits per sample
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint16(2)) // 块对齐
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint16(16)) // 每样本位数
|
||||
buf.WriteString("data")
|
||||
_ = binary.Write(buf, binary.LittleEndian, uint32(dataLen))
|
||||
buf.Write(make([]byte, dataLen))
|
||||
|
||||
Reference in new issue
Block a user