b1e89c606e
- DashScope WebSocket STT 客户端 (gummy-chat-v1) - 双引擎架构: DashScope 优先, Whisper 本地回退 - 实时流式 STT WebSocket 端点 - DevTools 模型搜索框焦点修复 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
37 lines
897 B
Go
37 lines
897 B
Go
package config
|
|
|
|
import "os"
|
|
|
|
// Config STT 语音识别服务配置
|
|
type Config struct {
|
|
Port string
|
|
WhisperBinary string
|
|
WhisperModel string
|
|
WhisperLanguage string
|
|
MaxAudioSize int64 // 字节
|
|
|
|
// DashScope STT 配置
|
|
DashScopeAPIKey string
|
|
DashScopeModel string
|
|
}
|
|
|
|
// Load 从环境变量加载配置
|
|
func Load() *Config {
|
|
return &Config{
|
|
Port: getEnv("PORT", "8093"),
|
|
WhisperBinary: getEnv("WHISPER_BINARY", "./whisper.cpp/main"),
|
|
WhisperModel: getEnv("WHISPER_MODEL", "./whisper.cpp/models/ggml-small.bin"),
|
|
WhisperLanguage: getEnv("WHISPER_LANGUAGE", "zh"),
|
|
MaxAudioSize: 10 * 1024 * 1024, // 10MB
|
|
DashScopeAPIKey: getEnv("DASHSCOPE_API_KEY", ""),
|
|
DashScopeModel: getEnv("DASHSCOPE_STT_MODEL", "gummy-chat-v1"),
|
|
}
|
|
}
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if v := os.Getenv(key); v != "" {
|
|
return v
|
|
}
|
|
return fallback
|
|
}
|