|
@@ -16,25 +16,21 @@ class TTS:
|
|
|
def get_pw_zm(cls, text):
|
|
|
max_retries = 3
|
|
|
for attempt in range(max_retries):
|
|
|
- # token = Material.get_cookie_data("KsoMsyP2ghleM9tzBfmcEEXBnXg", "U1gySe", "硅语")
|
|
|
- url = "https://videopre.piaoquantv.com/longvideoapi/producevideo/listeningTextSpeech"
|
|
|
-
|
|
|
- payload = {
|
|
|
- "machineCode": "fd5287b1-ccde-46db-8068-e50a58231a1a",
|
|
|
- "appType": "8",
|
|
|
- "produceVoiceConfigJson": '{"voice":"zhiyuan","channel":"aliyun","speechRate":0,"pitchRate":0,"volume":100}',
|
|
|
- "text": text,
|
|
|
- "versionName": "2.5.2",
|
|
|
- "buildCode": "38",
|
|
|
- "versionCode": "38",
|
|
|
- "token": "9396f509996e4575a7733f59604719efec6fde7a"
|
|
|
- }
|
|
|
+ url = "http://api.piaoquantv.com/produce-center/speechSynthesis"
|
|
|
+ payload = json.dumps({
|
|
|
+ "params": {
|
|
|
+ "text": text,
|
|
|
+ "vocie": "zhiyuan",
|
|
|
+ "format": "pcm",
|
|
|
+ "volume": 70,
|
|
|
+ "speechRate": 0,
|
|
|
+ "pitchRate": 0
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
headers = {
|
|
|
- 'Cookie': 'JSESSIONID=1204A84BECB3CB8AD3FDF765E57E2942'
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
wait_time = random.uniform(1, 10)
|
|
|
time.sleep(wait_time)
|
|
|
try:
|
|
@@ -46,13 +42,13 @@ class TTS:
|
|
|
return mp3
|
|
|
else:
|
|
|
if attempt == max_retries - 1:
|
|
|
- Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频cookie过期,请及时更换', '张勇')
|
|
|
+ Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频失败,请关注', '张勇')
|
|
|
return None
|
|
|
except Exception:
|
|
|
if attempt == max_retries - 1:
|
|
|
- Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频cookie过期,请及时更换', '张勇')
|
|
|
+ Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频失败,请关注', '张勇')
|
|
|
return None
|
|
|
- Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频cookie过期,请及时更换', '张勇')
|
|
|
+ Feishu.bot("zhangyong", '机器自动改造消息通知', f'获取字幕音频失败,请关注', '张勇')
|
|
|
|
|
|
|
|
|
|
|
@@ -260,7 +256,7 @@ if __name__ == '__main__':
|
|
|
# ]
|
|
|
# subprocess.run(command)
|
|
|
# print("完成")
|
|
|
- video_file = 'http://clipres.yishihui.com/longvideo/material/voice/pre/20240820/3f930929584e4af8b7c2d1552536ac891724162309557'
|
|
|
+ video_file = 'http://clipres.yishihui.com/longvideo/crawler/voice/pre/20240821/37fbb8cfc7f1439b8d8a032a1d01d37f1724219959925.mp3'
|
|
|
TTS.getSrt(video_file)
|
|
|
# result = subprocess.run(
|
|
|
# ["ffprobe", "-v", "error", "-show_entries", "format=duration",
|