'commit'
This commit is contained in:
@@ -78,5 +78,7 @@ ACCESS_TOKEN_EXPIRE_MINUTES = 300000 # 访问令牌过期时间(分钟)
|
|||||||
|
|
||||||
# 火山引擎相关信息
|
# 火山引擎相关信息
|
||||||
# 语音识别 https://console.volcengine.com/speech/service/10012?AppID=1513532196
|
# 语音识别 https://console.volcengine.com/speech/service/10012?AppID=1513532196
|
||||||
HS_ASR_APP_ID="1513532196"
|
HS_APP_ID= "1513532196"
|
||||||
HS_ASR_TOKEN="ti2NW-kbjIbkzc6BK55actnI_wTR8xkH"
|
HS_ACCESS_TOKEN= "ti2NW-kbjIbkzc6BK55actnI_wTR8xkH"
|
||||||
|
HS_CLUSTER_ID="volcano_tts"
|
||||||
|
HS_VOICE_TYPE = "zh_female_wanwanxiaohe_moon_bigtts" # 中文女声 湾湾小何
|
||||||
|
60
dsLightRag/Test/tts_http_demo.py
Normal file
60
dsLightRag/Test/tts_http_demo.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
'''
|
||||||
|
requires Python 3.6 or later
|
||||||
|
pip install requests
|
||||||
|
'''
|
||||||
|
import base64
|
||||||
|
import json
|
||||||
|
import uuid
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from Config.Config import HS_APP_ID, HS_ACCESS_TOKEN, HS_CLUSTER_ID, HS_VOICE_TYPE
|
||||||
|
|
||||||
|
appid = HS_APP_ID
|
||||||
|
access_token= HS_ACCESS_TOKEN
|
||||||
|
cluster = HS_CLUSTER_ID
|
||||||
|
|
||||||
|
voice_type = HS_VOICE_TYPE
|
||||||
|
host = "openspeech.bytedance.com"
|
||||||
|
api_url = f"https://{host}/api/v1/tts"
|
||||||
|
|
||||||
|
header = {"Authorization": f"Bearer;{access_token}"}
|
||||||
|
|
||||||
|
request_json = {
|
||||||
|
"app": {
|
||||||
|
"appid": appid,
|
||||||
|
"token": "access_token",
|
||||||
|
"cluster": cluster
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"uid": "388808087185088"
|
||||||
|
},
|
||||||
|
"audio": {
|
||||||
|
"voice_type": voice_type,
|
||||||
|
"encoding": "mp3",
|
||||||
|
"speed_ratio": 1.0,
|
||||||
|
"volume_ratio": 1.0,
|
||||||
|
"pitch_ratio": 1.0,
|
||||||
|
},
|
||||||
|
"request": {
|
||||||
|
"reqid": str(uuid.uuid4()),
|
||||||
|
"text": "字节跳动语音合成",
|
||||||
|
"text_type": "plain",
|
||||||
|
"operation": "query",
|
||||||
|
"with_frontend": 1,
|
||||||
|
"frontend_type": "unitTson"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
resp = requests.post(api_url, json.dumps(request_json), headers=header)
|
||||||
|
print(f"resp body: \n{resp.json()}")
|
||||||
|
if "data" in resp.json():
|
||||||
|
data = resp.json()["data"]
|
||||||
|
file_to_save = open("test_submit.mp3", "wb")
|
||||||
|
file_to_save.write(base64.b64decode(data))
|
||||||
|
except Exception as e:
|
||||||
|
e.with_traceback()
|
@@ -3,13 +3,13 @@ import time
|
|||||||
import uuid
|
import uuid
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from Config.Config import HS_ASR_APP_ID, HS_ASR_TOKEN
|
from Config.Config import HS_APP_ID, HS_ACCESS_TOKEN
|
||||||
|
|
||||||
|
|
||||||
class ASRClient:
|
class ASRClient:
|
||||||
def __init__(self, appid=None, token=None, file_url=None):
|
def __init__(self, appid=None, token=None, file_url=None):
|
||||||
self.appid = appid or HS_ASR_APP_ID
|
self.appid = appid or HS_APP_ID
|
||||||
self.token = token or HS_ASR_TOKEN
|
self.token = token or HS_ACCESS_TOKEN
|
||||||
self.file_url = file_url or "https://ttc-advisory-oss.oss-cn-hangzhou.aliyuncs.com/lark_audio/int/T_APLA_1941058348698869760.mp3"
|
self.file_url = file_url or "https://ttc-advisory-oss.oss-cn-hangzhou.aliyuncs.com/lark_audio/int/T_APLA_1941058348698869760.mp3"
|
||||||
self.submit_url = "https://openspeech-direct.zijieapi.com/api/v3/auc/bigmodel/submit"
|
self.submit_url = "https://openspeech-direct.zijieapi.com/api/v3/auc/bigmodel/submit"
|
||||||
self.query_url = "https://openspeech-direct.zijieapi.com/api/v3/auc/bigmodel/query"
|
self.query_url = "https://openspeech-direct.zijieapi.com/api/v3/auc/bigmodel/query"
|
||||||
|
Reference in New Issue
Block a user