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
@@ -2,76 +2,76 @@ package voice
|
||||
|
||||
import "context"
|
||||
|
||||
// Provider is one rung in the voice degradation chain. It may implement zero,
|
||||
// one, or both directions; a nil return means that direction is not available
|
||||
// on this rung and the chain moves to the next.
|
||||
// Provider 是语音降级链上的一级。它可实现零个、一个
|
||||
// 或两个方向;返回 nil 表示该方向在此级上不可用,
|
||||
// 链会移向下一级。
|
||||
type Provider interface {
|
||||
// Name returns a stable provider identifier.
|
||||
// Name 返回稳定的提供方标识。
|
||||
Name() string
|
||||
// STT returns the speech-to-text implementation, or nil when the provider
|
||||
// cannot transcribe.
|
||||
// STT 返回语音转文字实现,提供方无法转写时
|
||||
// 返回 nil。
|
||||
STT() STT
|
||||
// TTS returns the text-to-speech implementation, or nil when the provider
|
||||
// cannot synthesize.
|
||||
// TTS 返回文字转语音实现,提供方无法合成时
|
||||
// 返回 nil。
|
||||
TTS() TTS
|
||||
}
|
||||
|
||||
// StaticProvider is a Provider with a fixed name whose STT/TTS are set at
|
||||
// construction. It is used by the concrete providers below.
|
||||
// StaticProvider 是名字固定、STT/TTS 在构造时设定的
|
||||
// Provider。下面各具体提供方都用它。
|
||||
type StaticProvider struct {
|
||||
name string
|
||||
stt STT
|
||||
tts TTS
|
||||
}
|
||||
|
||||
// Name returns the provider identifier.
|
||||
// Name 返回提供方标识。
|
||||
func (p *StaticProvider) Name() string { return p.name }
|
||||
|
||||
// STT returns the configured STT, or nil.
|
||||
// STT 返回配置的 STT,可能为 nil。
|
||||
func (p *StaticProvider) STT() STT { return p.stt }
|
||||
|
||||
// TTS returns the configured TTS, or nil.
|
||||
// TTS 返回配置的 TTS,可能为 nil。
|
||||
func (p *StaticProvider) TTS() TTS { return p.tts }
|
||||
|
||||
// NewProvider builds a Provider with the given name and optional directions it
|
||||
// supports.
|
||||
// NewProvider 用给定名字及其支持的可选方向构造一个
|
||||
// Provider。
|
||||
func NewProvider(name string, stt STT, tts TTS) *StaticProvider {
|
||||
return &StaticProvider{name: name, stt: stt, tts: tts}
|
||||
}
|
||||
|
||||
// CloudProvider is the cloud rung of the chain. It is an adaptation point: the
|
||||
// real STT/TTS implementations are wired in via NewProvider with cloud adapters.
|
||||
// CloudProvider 是链上的云端一级。它是一个适配点:
|
||||
// 真实的 STT/TTS 实现经 NewProvider 与云端适配器接入。
|
||||
func CloudProvider(stt STT, tts TTS) *StaticProvider {
|
||||
return NewProvider("cloud", stt, tts)
|
||||
}
|
||||
|
||||
// LocalProvider is the local-model rung of the chain.
|
||||
// LocalProvider 是链上的本地模型一级。
|
||||
func LocalProvider(stt STT, tts TTS) *StaticProvider {
|
||||
return NewProvider("local", stt, tts)
|
||||
}
|
||||
|
||||
// EdgeTTSProvider is the edge-tts rung (text-to-speech only).
|
||||
// EdgeTTSProvider 是 edge-tts 一级(仅文字转语音)。
|
||||
func EdgeTTSProvider(tts TTS) *StaticProvider {
|
||||
return NewProvider("edge-tts", nil, tts)
|
||||
}
|
||||
|
||||
// EspeakProvider is the espeak rung (text-to-speech only).
|
||||
// EspeakProvider 是 espeak 一级(仅文字转语音)。
|
||||
func EspeakProvider(tts TTS) *StaticProvider {
|
||||
return NewProvider("espeak", nil, tts)
|
||||
}
|
||||
|
||||
// SilentProvider is the terminal rung. It always succeeds, returning an empty
|
||||
// transcription and empty audio, so a chain that includes it never errors.
|
||||
// SilentProvider 是末端一级。它总是成功,返回空
|
||||
// 转写与空音频,因此包含它的链永不报错。
|
||||
func SilentProvider() *StaticProvider {
|
||||
return NewProvider("silent", silenceSTT{}, silenceTTS{})
|
||||
}
|
||||
|
||||
// silenceSTT is the silent STT rung; it returns an empty transcription.
|
||||
// silenceSTT 是静默 STT 一级;它返回空转写。
|
||||
type silenceSTT struct{}
|
||||
|
||||
func (silenceSTT) STT(_ context.Context, _ Audio) (string, error) { return "", nil }
|
||||
|
||||
// silenceTTS is the silent TTS rung; it returns empty audio.
|
||||
// silenceTTS 是静默 TTS 一级;它返回空音频。
|
||||
type silenceTTS struct{}
|
||||
|
||||
func (silenceTTS) TTS(_ context.Context, _ string) (Audio, error) {
|
||||
|
||||
Reference in new issue
Block a user