|
@@ -12,49 +12,92 @@ from common import Material, Feishu
|
|
|
|
|
|
|
|
|
class TTS:
|
|
|
-
|
|
|
@classmethod
|
|
|
def get_pw_zm(cls, text):
|
|
|
max_retries = 3
|
|
|
for attempt in range(max_retries):
|
|
|
- token = Material.get_cookie_data("KsoMsyP2ghleM9tzBfmcEEXBnXg", "U1gySe", "硅语")
|
|
|
- url = "https://zh.api.guiji.cn/avatar2c/tool/sec_tts"
|
|
|
+ # token = Material.get_cookie_data("KsoMsyP2ghleM9tzBfmcEEXBnXg", "U1gySe", "硅语")
|
|
|
+ url = "https://videopre.piaoquantv.com/longvideoapi/producevideo/listeningTextSpeech"
|
|
|
|
|
|
- payload = json.dumps({
|
|
|
+ payload = {
|
|
|
+ "machineCode": "fd5287b1-ccde-46db-8068-e50a58231a1a",
|
|
|
+ "appType": "8",
|
|
|
+ "produceVoiceConfigJson": '{"voice":"stanley","channel":"aliyun","speechRate":0,"pitchRate":0,"volume":100}',
|
|
|
"text": text,
|
|
|
- "speaker_id": "160"
|
|
|
- })
|
|
|
+ "versionName": "2.5.2",
|
|
|
+ "buildCode": "38",
|
|
|
+ "versionCode": "38",
|
|
|
+ "token": "9396f509996e4575a7733f59604719efec6fde7a"
|
|
|
+ }
|
|
|
+
|
|
|
headers = {
|
|
|
- 'accept': 'application/json, text/plain, */*',
|
|
|
- 'content-type': 'application/json',
|
|
|
- 'cookie': 'anylangIsLogin=true',
|
|
|
- 'origin': 'https://app.guiji.cn',
|
|
|
- 'pragma': 'no-cache',
|
|
|
- 'referer': 'https://app.guiji.cn/',
|
|
|
- 'token': token
|
|
|
+ 'Cookie': 'JSESSIONID=1204A84BECB3CB8AD3FDF765E57E2942'
|
|
|
}
|
|
|
- wait_time = random.uniform(5, 20)
|
|
|
+
|
|
|
+
|
|
|
+ wait_time = random.uniform(1, 10)
|
|
|
time.sleep(wait_time)
|
|
|
try:
|
|
|
- proxies = {
|
|
|
- "http": "http://t10952018781111:1ap37oc3@d844.kdltps.com:15818",
|
|
|
- "https": "http://t10952018781111:1ap37oc3@d844.kdltps.com:15818"
|
|
|
- }
|
|
|
- response = requests.request("POST", url, headers=headers, data=payload, proxies=proxies)
|
|
|
+ response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
response = response.json()
|
|
|
code = response["code"]
|
|
|
- if code == 200:
|
|
|
+ if code == 0:
|
|
|
mp3 = response["data"]
|
|
|
return mp3
|
|
|
else:
|
|
|
if attempt == max_retries - 1:
|
|
|
- Feishu.bot("zhangyong", '机器自动改造消息通知', f'硅语错误请排查', '张勇')
|
|
|
+ Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频cookie过期,请及时更换', '张勇')
|
|
|
return None
|
|
|
except Exception:
|
|
|
if attempt == max_retries - 1:
|
|
|
- Feishu.bot("zhangyong", '机器自动改造消息通知', f'硅语错误请排查', '张勇')
|
|
|
+ Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频cookie过期,请及时更换', '张勇')
|
|
|
return None
|
|
|
- Feishu.bot("zhangyong", '机器自动改造消息通知', f'硅语cookie过期,请及时更换', '张勇')
|
|
|
+ Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频cookie过期,请及时更换', '张勇')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ # @classmethod
|
|
|
+ # def get_pw_zm(cls, text):
|
|
|
+ # max_retries = 3
|
|
|
+ # for attempt in range(max_retries):
|
|
|
+ # token = Material.get_cookie_data("KsoMsyP2ghleM9tzBfmcEEXBnXg", "U1gySe", "硅语")
|
|
|
+ # url = "https://zh.api.guiji.cn/avatar2c/tool/sec_tts"
|
|
|
+ #
|
|
|
+ # payload = json.dumps({
|
|
|
+ # "text": text,
|
|
|
+ # "speaker_id": "160"
|
|
|
+ # })
|
|
|
+ # headers = {
|
|
|
+ # 'accept': 'application/json, text/plain, */*',
|
|
|
+ # 'content-type': 'application/json',
|
|
|
+ # 'cookie': 'anylangIsLogin=true',
|
|
|
+ # 'origin': 'https://app.guiji.cn',
|
|
|
+ # 'pragma': 'no-cache',
|
|
|
+ # 'referer': 'https://app.guiji.cn/',
|
|
|
+ # 'token': token
|
|
|
+ # }
|
|
|
+ # wait_time = random.uniform(5, 20)
|
|
|
+ # time.sleep(wait_time)
|
|
|
+ # try:
|
|
|
+ # proxies = {
|
|
|
+ # "http": "http://t10952018781111:1ap37oc3@d844.kdltps.com:15818",
|
|
|
+ # "https": "http://t10952018781111:1ap37oc3@d844.kdltps.com:15818"
|
|
|
+ # }
|
|
|
+ # response = requests.request("POST", url, headers=headers, data=payload, proxies=proxies)
|
|
|
+ # response = response.json()
|
|
|
+ # code = response["code"]
|
|
|
+ # if code == 200:
|
|
|
+ # mp3 = response["data"]
|
|
|
+ # return mp3
|
|
|
+ # else:
|
|
|
+ # if attempt == max_retries - 1:
|
|
|
+ # Feishu.bot("zhangyong", '机器自动改造消息通知', f'硅语错误请排查', '张勇')
|
|
|
+ # return None
|
|
|
+ # except Exception:
|
|
|
+ # if attempt == max_retries - 1:
|
|
|
+ # Feishu.bot("zhangyong", '机器自动改造消息通知', f'硅语错误请排查', '张勇')
|
|
|
+ # return None
|
|
|
+ # Feishu.bot("zhangyong", '机器自动改造消息通知', f'硅语cookie过期,请及时更换', '张勇')
|
|
|
|
|
|
"""
|
|
|
音频下载到本地
|
|
@@ -217,8 +260,8 @@ if __name__ == '__main__':
|
|
|
# ]
|
|
|
# subprocess.run(command)
|
|
|
# print("完成")
|
|
|
- video_file = '"千钧"中的“钧”是古代的一种重量单位,1钧等于30斤。因此,“千钧”就是1000钧,等于30,000斤。'
|
|
|
- TTS.get_pw_zm(video_file)
|
|
|
+ video_file = 'http://clipres.yishihui.com/longvideo/material/voice/pre/20240820/3f930929584e4af8b7c2d1552536ac891724162309557'
|
|
|
+ TTS.getSrt(video_file)
|
|
|
# result = subprocess.run(
|
|
|
# ["ffprobe", "-v", "error", "-show_entries", "format=duration",
|
|
|
# "-of", "default=noprint_wrappers=1:nokey=1", video_file],
|