@@ -37,7 +37,7 @@ def load_config():
37
37
38
38
try :
39
39
config = load_config ()
40
- API_TOKEN = config ['server' ]['token ' ]
40
+ API_TOKEN = config ['server' ]['authorization ' ]
41
41
except Exception as e :
42
42
logger .error (f"配置加载失败: { e } " )
43
43
raise
@@ -99,7 +99,7 @@ def ensure_16k_wav(audio_bytes):
99
99
100
100
@app .post ("/register" , summary = "声纹注册" )
101
101
async def register (
102
- token : str = Header (..., description = "接口令牌" ),
102
+ authorization : str = Header (..., description = "接口令牌" , alias = "authorization " ),
103
103
speaker_id : str = Form (..., description = "说话人ID" ),
104
104
file : UploadFile = File (..., description = "WAV音频文件" )
105
105
):
@@ -112,7 +112,7 @@ async def register(
112
112
返回:
113
113
注册结果
114
114
"""
115
- check_token (token )
115
+ check_token (authorization )
116
116
audio_path = None
117
117
try :
118
118
audio_bytes = await file .read ()
@@ -131,7 +131,7 @@ async def register(
131
131
132
132
@app .post ("/identify" , summary = "声纹识别" )
133
133
async def identify (
134
- token : str = Header (..., description = "接口令牌" ),
134
+ authorization : str = Header (..., description = "接口令牌" , alias = "authorization " ),
135
135
speaker_ids : str = Form (..., description = "候选说话人ID,逗号分隔" ),
136
136
file : UploadFile = File (..., description = "WAV音频文件" )
137
137
):
@@ -144,7 +144,7 @@ async def identify(
144
144
返回:
145
145
识别结果(说话人ID、相似度分数)
146
146
"""
147
- check_token (token )
147
+ check_token (authorization )
148
148
candidate_ids = [x .strip () for x in speaker_ids .split ("," ) if x .strip ()]
149
149
if not candidate_ids :
150
150
logger .warning ("候选说话人ID不能为空。" )
0 commit comments