Skip to content

Commit d7b0a72

Browse files
committed
fix(gsvi_tts): Adjust wherever the Authorization header is built to only include it when self.api_key is truthy
Delete some comments
1 parent eb000bf commit d7b0a72

1 file changed

Lines changed: 5 additions & 37 deletions

File tree

astrbot/core/provider/sources/gsvi_tts_source.py

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,6 @@
99
from ..provider import TTSProvider
1010
from ..register import register_provider_adapter
1111

12-
# 贴个作为参考
13-
# curl -X 'POST' \
14-
# 'https://gsv2p.acgnai.top/infer_single' \
15-
# -H 'accept: application/json' \
16-
# -H 'Authorization: Bearer 2e3d9b7*************************' \
17-
# -H 'Content-Type: application/json' \
18-
# -d '{
19-
# "version": "v4",
20-
# "model_name": "原神-中文-芙宁娜_ZH",
21-
# "prompt_text_lang": "中文",
22-
# "emotion": "默认",
23-
# "text": "还是面向人工智能编程的",
24-
# "text_lang": "中文",
25-
# "top_k": 10,
26-
# "top_p": 1,
27-
# "temperature": 1,
28-
# "text_split_method": "按标点符号切",
29-
# "batch_size": 1,
30-
# "batch_threshold": 0.75,
31-
# "split_bucket": true,
32-
# "speed_facter": 1,
33-
# "fragment_interval": 0.3,
34-
# "media_type": "wav",
35-
# "parallel_infer": true,
36-
# "repetition_penalty": 1.35,
37-
# "seed": -1,
38-
# "sample_steps": 16,
39-
# "if_sr": false
40-
# }'
41-
42-
# {
43-
# "msg": "合成成功",
44-
# "audio_url": "https://gsv2p.acgnai.top/outputs/9264dd20655fa31660376801639c9a73.wav"
45-
# }
46-
47-
# {"msg":"参数错误","audio_url":""}
4812

4913
@register_provider_adapter(
5014
"gsvi_tts_api",
@@ -72,6 +36,10 @@ async def get_audio(self, text: str) -> str:
7236
path = Path(temp_dir) / f"gsvi_tts_{uuid.uuid4()}.wav"
7337
url = f"{self.api_base}/infer_single"
7438

39+
headers = {"Content-Type": "application/json"}
40+
if self.api_key:
41+
headers["Authorization"] = f"Bearer {self.api_key}"
42+
7543
data = {
7644
"dl_url": self.api_base,
7745
"version": self.version,
@@ -84,7 +52,7 @@ async def get_audio(self, text: str) -> str:
8452

8553
async with aiohttp.ClientSession() as session:
8654
async with session.post(
87-
url, json=data, headers={"Authorization": f"Bearer {self.api_key}"}
55+
url, json=data, headers=headers
8856
) as response:
8957
if response.status == 200:
9058
resp_json = await response.json()

0 commit comments

Comments
 (0)