Spaces:
Sleeping
Sleeping
JiaenLiu
commited on
Commit
•
7511df3
1
Parent(s):
144c78b
in progress
Browse filesFormer-commit-id: be461c9f32bacab23a5b56b51f601a7afe3ad51d
- README.md +4 -0
- __pycache__/srt2ass.cpython-38.pyc +0 -0
- pipeline.py +6 -2
README.md
CHANGED
@@ -14,6 +14,10 @@ quick start:
|
|
14 |
|
15 |
example online: python3 pipeline.py --link https://www.youtube.com/watch?v=61c4dn6851g --download ./downloads --result ./results --video_name SO_I_CHOSE_RANDOM
|
16 |
|
|
|
|
|
|
|
|
|
17 |
example offline: python3 pipeline.py --local_path test_translation.m4a --result ./results --video_name test_translation
|
18 |
|
19 |
example text input: python pipeline.py --text_file "/home/jiaenliu/project-t/results/huanghe_translation_en.txt" --result "/home/jiaenliu/project-t/results" --video_name "huanghe_test"
|
|
|
14 |
|
15 |
example online: python3 pipeline.py --link https://www.youtube.com/watch?v=61c4dn6851g --download ./downloads --result ./results --video_name SO_I_CHOSE_RANDOM
|
16 |
|
17 |
+
python3 pipeline.py --link https://www.youtube.com/watch?v=VrigMmXt9A0 --video_name Ukraine_and_its_Global_Impact
|
18 |
+
|
19 |
+
python3 pipeline.py --video_file '/home/jiaenliu/project-t/downloads/audio/Ukraine_and_its_Global_Impact.mp4' -v --video_name Ukraine_and_its_Global_Impact
|
20 |
+
|
21 |
example offline: python3 pipeline.py --local_path test_translation.m4a --result ./results --video_name test_translation
|
22 |
|
23 |
example text input: python pipeline.py --text_file "/home/jiaenliu/project-t/results/huanghe_translation_en.txt" --result "/home/jiaenliu/project-t/results" --video_name "huanghe_test"
|
__pycache__/srt2ass.cpython-38.pyc
ADDED
Binary file (13.9 kB). View file
|
|
pipeline.py
CHANGED
@@ -119,8 +119,8 @@ if not args.only_srt:
|
|
119 |
print('ASS subtitle saved as: ' + assSub_en)
|
120 |
|
121 |
# Split the video script by sentences and create chunks within the token limit
|
122 |
-
n_threshold =
|
123 |
-
script_split = script_input.split('
|
124 |
|
125 |
script_arr = []
|
126 |
script = ""
|
@@ -142,12 +142,15 @@ for s in script_arr:
|
|
142 |
model=model_name,
|
143 |
messages = [
|
144 |
{"role": "system", "content": "You are a helpful assistant that translates English to Chinese and have decent background in starcraft2."},
|
|
|
|
|
145 |
{"role": "user", "content": 'Translate the following English text to Chinese: "{}"'.format(s)}
|
146 |
],
|
147 |
temperature=0.15
|
148 |
)
|
149 |
with open(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt", 'a+') as f:
|
150 |
f.write(response['choices'][0]['message']['content'].strip())
|
|
|
151 |
|
152 |
if model_name == "text-davinci-003":
|
153 |
prompt = f"Please help me translate this into Chinese:\n\n{s}\n\n"
|
@@ -164,6 +167,7 @@ for s in script_arr:
|
|
164 |
|
165 |
with open(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt", 'a+') as f:
|
166 |
f.write(response['choices'][0]['text'].strip())
|
|
|
167 |
|
168 |
if not args.only_srt:
|
169 |
assSub_zh = srt2ass(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt", "default", "No", "Modest")
|
|
|
119 |
print('ASS subtitle saved as: ' + assSub_en)
|
120 |
|
121 |
# Split the video script by sentences and create chunks within the token limit
|
122 |
+
n_threshold = 1000 # Token limit for the GPT-3 model
|
123 |
+
script_split = script_input.split('\n')
|
124 |
|
125 |
script_arr = []
|
126 |
script = ""
|
|
|
142 |
model=model_name,
|
143 |
messages = [
|
144 |
{"role": "system", "content": "You are a helpful assistant that translates English to Chinese and have decent background in starcraft2."},
|
145 |
+
{"role": "system", "content": "Your translation has to keep the orginal format and be as accurate as possible."},
|
146 |
+
{"role": "system", "content": "There is no need for you to add any comments or notes."},
|
147 |
{"role": "user", "content": 'Translate the following English text to Chinese: "{}"'.format(s)}
|
148 |
],
|
149 |
temperature=0.15
|
150 |
)
|
151 |
with open(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt", 'a+') as f:
|
152 |
f.write(response['choices'][0]['message']['content'].strip())
|
153 |
+
f.write("\n")
|
154 |
|
155 |
if model_name == "text-davinci-003":
|
156 |
prompt = f"Please help me translate this into Chinese:\n\n{s}\n\n"
|
|
|
167 |
|
168 |
with open(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt", 'a+') as f:
|
169 |
f.write(response['choices'][0]['text'].strip())
|
170 |
+
f.write("\n")
|
171 |
|
172 |
if not args.only_srt:
|
173 |
assSub_zh = srt2ass(f"{RESULT_PATH}/{VIDEO_NAME}/{VIDEO_NAME}_zh.srt", "default", "No", "Modest")
|