'commit'
This commit is contained in:
@@ -88,3 +88,9 @@ HS_CLUSTER_ID = "volcano_tts"
|
|||||||
# 音色体验:https://www.volcengine.com/product/tts
|
# 音色体验:https://www.volcengine.com/product/tts
|
||||||
HS_VOICE_TYPE = "zh_female_wanwanxiaohe_moon_bigtts" # 中文女声 湾湾小何
|
HS_VOICE_TYPE = "zh_female_wanwanxiaohe_moon_bigtts" # 中文女声 湾湾小何
|
||||||
HS_VOICE_TYPE_QINCANG = "BV701_V2_streaming" # 中年男声,用于朗读古诗
|
HS_VOICE_TYPE_QINCANG = "BV701_V2_streaming" # 中年男声,用于朗读古诗
|
||||||
|
|
||||||
|
|
||||||
|
#LibLib的配置
|
||||||
|
LIBLIB_URL="https://openapi.liblibai.cloud"
|
||||||
|
LIBLIB_ACCESSKEY="sOCtVLVTNOZkRMajlhzCmg"
|
||||||
|
LIBLIB_SECRETKEY="PUe8QTRG9i0G9EbpedHmIpLQ0FyxoYY9"
|
Binary file not shown.
66
dsLightRag/Liblib/T1_VersionGet.py
Normal file
66
dsLightRag/Liblib/T1_VersionGet.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import hmac
|
||||||
|
from hashlib import sha1
|
||||||
|
import base64
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from Config.Config import LIBLIB_SECRETKEY, LIBLIB_URL, LIBLIB_ACCESSKEY
|
||||||
|
|
||||||
|
|
||||||
|
def make_sign(uri):
|
||||||
|
"""
|
||||||
|
生成签名
|
||||||
|
"""
|
||||||
|
# 当前毫秒时间戳
|
||||||
|
timestamp = str(int(time.time() * 1000))
|
||||||
|
# 随机字符串
|
||||||
|
signature_nonce = str(uuid.uuid4())
|
||||||
|
# 拼接请求数据
|
||||||
|
content = '&'.join((uri, timestamp, signature_nonce))
|
||||||
|
# 生成签名
|
||||||
|
digest = hmac.new(LIBLIB_SECRETKEY.encode(), content.encode(), sha1).digest()
|
||||||
|
# 移除为了补全base64位数而填充的尾部等号
|
||||||
|
sign = base64.urlsafe_b64encode(digest).rstrip(b'=').decode()
|
||||||
|
return sign, timestamp, signature_nonce
|
||||||
|
|
||||||
|
|
||||||
|
# 请求API接口的uri地址
|
||||||
|
uri = "/api/model/version/get"
|
||||||
|
Signature, timestamp, signature_nonce = make_sign(uri)
|
||||||
|
url = f"{LIBLIB_URL}{uri}?AccessKey={LIBLIB_ACCESSKEY}&Signature={Signature}&Timestamp={timestamp}&SignatureNonce={signature_nonce}"
|
||||||
|
|
||||||
|
# 设置请求头
|
||||||
|
headers = {"Content-Type": "application/json"}
|
||||||
|
version_uuid = "4bb1335feb1e4d2eafe5a77bb93e861f"
|
||||||
|
# 准备请求体数据
|
||||||
|
request_body = {"version_uuid": version_uuid}
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 发送POST请求
|
||||||
|
response = requests.post(url, headers=headers, data=json.dumps(request_body))
|
||||||
|
response.raise_for_status() # 检查请求是否成功
|
||||||
|
print(response)
|
||||||
|
# 解析响应数据
|
||||||
|
result = response.json()
|
||||||
|
print("API响应结果:")
|
||||||
|
print(f"模型名称: {result.get('model_name')}")
|
||||||
|
print(f"版本号: {result.get('version_name')}")
|
||||||
|
print(f"是否可商用: {'是' if result.get('commercial_use') == '1' else '否'}")
|
||||||
|
print(f"模型链接: {result.get('model_url')}")
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"请求发生错误: {str(e)}")
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"version_uuid": "21df5d84cca74f7a885ba672b5a80d19",//LiblibAI官网模型链接后缀
|
||||||
|
"model_name": "AWPortrait XL"
|
||||||
|
"version_name": "1.1"
|
||||||
|
"baseAlgo": "基础算法 XL",
|
||||||
|
"show_type": "1",//公开可用的模型
|
||||||
|
"commercial_use": "1",//可商用为1,不可商用为0
|
||||||
|
"model_url": "https://www.liblib.art/modelinfo/f8b990b20cb943e3aa0e96f34099d794?versionUuid=21df5d84cca74f7a885ba672b5a80d19"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
Reference in New Issue
Block a user