Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions PyDeepLX/PyDeepLX.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ def translate(
},
"timestamp": getTimestamp(iCount),
"commonJobParams": {
"wasSpoken": False,
"transcribe_as": "",
"quality": "normal",
"mode": "translate",
"textType": "plaintext"
},
},
}

postDataStr = json.dumps(postData, ensure_ascii=False)

if (id + 5) % 29 == 0 or (id + 3) % 13 == 0:
Expand Down Expand Up @@ -117,10 +119,18 @@ def translate(
return targetText

targetTextArray = []
for item in respJson["result"]["texts"][0]["alternatives"]:
targetTextArray.append(item["text"])
alternatives = respJson["result"]["texts"][0]["alternatives"]
if len(alternatives) == 0:
print("No found alternatives")
targetText = respJson["result"]["texts"][0]["text"]
targetTextArray.append(targetText)
if printResult:
print(item["text"])
print(targetText)
else:
for item in alternatives:
targetTextArray.append(item["text"])
if printResult:
print(item["text"])

return targetTextArray

Expand Down