Skip to content

Commit 6660864

Browse files
committed
feat: add voice
Signed-off-by: Xinwei Xiong <[email protected]>
1 parent 35e31ff commit 6660864

File tree

12 files changed

+396
-9
lines changed

12 files changed

+396
-9
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ VOICEFLOW_ASSEMBLYAI_API_KEY='your_assemblyai_api_key' # AssemblyAI API 密钥
2020

2121
# 语音服务端口配置
2222
VOICEFLOW_SERVER_PORT=18080 # VoiceFlow 服务端口
23+
24+
# Huoshan 配置
25+
VOICEFLOW_HUOSHAN_ACCESS_KEY=''
26+
VOICEFLOW_HUOSHAN_APP_KEY=''
27+
VOICEFLOW_HUOSHAN_WS_URL='wss://openspeech.bytedance.com/api/v3/sauc/bigmode

cmd/voiceflow/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ func run(cmd *cobra.Command, args []string) error {
6060
// 记录启动信息
6161
logger.InfoContextf(ctx, "Starting VoiceFlow server with config: %+v", cfg)
6262

63+
serverpkg.InitServices()
64+
6365
// Set up HTTP server
6466
mux := http.NewServeMux()
6567
mux.Handle("/", http.FileServer(http.Dir("./web")))

configs/config.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ minio:
1414
secure: true # 如果需要使用 HTTPS 连接,设置为 true
1515

1616
stt:
17-
provider: assemblyai # 可选值:azure、google、local、assemblyai
17+
provider: huoshan # 可选值:azure、google、local、assemblyai、huoshan
1818

1919
tts:
2020
provider: google # 可选值:azure、google、local
@@ -32,7 +32,23 @@ google:
3232
tts_key: "your_google_tts_key"
3333

3434
openai:
35-
api_key: "your_openai_api_key"
35+
api_key: ""
36+
# OPENAI_BASE_URL='https://api.lqqq.cc/v1' # Global provider
37+
# OPENAI_BASE_URL='https://api.chatanywhere.cn' # International version
38+
# OPENAI_BASE_URL='https://api.chatanywhere.tech' # Domestic version
39+
# OPENAI_BASE_URL='https://api.chatanywhere.tech' # Domestic version
40+
base_url: ""
41+
42+
huoshan:
43+
access_key: ''
44+
app_key: ''
45+
ws_url: ''
46+
uid: "test"
47+
rate: 16000
48+
format: "pcm"
49+
bits: 16
50+
channel: 1
51+
codec: "pcm"
3652

3753
# 日志配置
3854
logging:
@@ -54,4 +70,4 @@ logging:
5470
report_caller: false
5571

5672
assemblyai:
57-
api_key: "your_assemblyai_api_key"
73+
api_key: ""

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/spf13/cobra v1.8.1
1717
github.com/spf13/viper v1.19.0
1818
github.com/stretchr/testify v1.9.0
19+
gopkg.in/natefinch/lumberjack.v2 v2.2.1
1920
)
2021

2122
require (
@@ -52,7 +53,6 @@ require (
5253
golang.org/x/sys v0.26.0 // indirect
5354
golang.org/x/text v0.19.0 // indirect
5455
gopkg.in/ini.v1 v1.67.0 // indirect
55-
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
5656
gopkg.in/yaml.v3 v3.0.1 // indirect
5757
nhooyr.io/websocket v1.8.7 // indirect
5858
)

internal/server/handlers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
)
2626

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

150150
// 根据新的配置重新初始化服务实例
151-
initServices()
151+
//initServices()
152152

153153
w.WriteHeader(http.StatusOK)
154154
w.Write([]byte("Configuration updated"))

0 commit comments

Comments
 (0)