Skip to content

Commit

Permalink
feat: add voice
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong <3293172751NSS@gmail.com>
  • Loading branch information
cubxxw committed Nov 1, 2024
1 parent 35e31ff commit 6660864
Show file tree
Hide file tree
Showing 12 changed files with 396 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ VOICEFLOW_ASSEMBLYAI_API_KEY='your_assemblyai_api_key' # AssemblyAI API 密钥

# 语音服务端口配置
VOICEFLOW_SERVER_PORT=18080 # VoiceFlow 服务端口

# Huoshan 配置
VOICEFLOW_HUOSHAN_ACCESS_KEY=''
VOICEFLOW_HUOSHAN_APP_KEY=''
VOICEFLOW_HUOSHAN_WS_URL='wss://openspeech.bytedance.com/api/v3/sauc/bigmode
2 changes: 2 additions & 0 deletions cmd/voiceflow/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ func run(cmd *cobra.Command, args []string) error {
// 记录启动信息
logger.InfoContextf(ctx, "Starting VoiceFlow server with config: %+v", cfg)

serverpkg.InitServices()

// Set up HTTP server
mux := http.NewServeMux()
mux.Handle("/", http.FileServer(http.Dir("./web")))
Expand Down
22 changes: 19 additions & 3 deletions configs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ minio:
secure: true # 如果需要使用 HTTPS 连接,设置为 true

stt:
provider: assemblyai # 可选值:azure、google、local、assemblyai
provider: huoshan # 可选值:azure、google、local、assemblyai、huoshan

tts:
provider: google # 可选值:azure、google、local
Expand All @@ -32,7 +32,23 @@ google:
tts_key: "your_google_tts_key"

openai:
api_key: "your_openai_api_key"
api_key: ""
# OPENAI_BASE_URL='https://api.lqqq.cc/v1' # Global provider
# OPENAI_BASE_URL='https://api.chatanywhere.cn' # International version
# OPENAI_BASE_URL='https://api.chatanywhere.tech' # Domestic version
# OPENAI_BASE_URL='https://api.chatanywhere.tech' # Domestic version
base_url: ""

huoshan:
access_key: ''
app_key: ''
ws_url: ''
uid: "test"
rate: 16000
format: "pcm"
bits: 16
channel: 1
codec: "pcm"

# 日志配置
logging:
Expand All @@ -54,4 +70,4 @@ logging:
report_caller: false

assemblyai:
api_key: "your_assemblyai_api_key"
api_key: ""
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

require (
Expand Down Expand Up @@ -52,7 +53,6 @@ require (
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect
)
4 changes: 2 additions & 2 deletions internal/server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
)

// 初始化服务实例
func initServices() {
func InitServices() {
cfg, err := config.GetConfig()
if err != nil {
logger.Fatalf("配置初始化失败: %v", err)
Expand Down Expand Up @@ -148,7 +148,7 @@ func (s *Server) HandleConfig(w http.ResponseWriter, r *http.Request) {
}

// 根据新的配置重新初始化服务实例
initServices()
//initServices()

w.WriteHeader(http.StatusOK)
w.Write([]byte("Configuration updated"))
Expand Down
Loading

0 comments on commit 6660864

Please sign in to comment.