JiaenLiu commited on
Commit
5d61b3b
2 Parent(s): 7511df3 94aacab

Merge branch

Browse files

Former-commit-id: daf0684aff6d0f12ea49dbf402ef90d9a3be46d5

Files changed (6) hide show
  1. .gitignore +2 -1
  2. .mp3 +0 -0
  3. README.md +28 -14
  4. __pycache__/srt2ass.cpython-310.pyc +0 -0
  5. pipeline.py +2 -5
  6. placeholder.mp3 +0 -0
.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  /downloads
2
  /results
3
- .DS_Store
 
 
1
  /downloads
2
  /results
3
+ .DS_Store
4
+ /__pycache__
.mp3 DELETED
Binary file (657 kB)
 
README.md CHANGED
@@ -6,13 +6,18 @@
6
  pip install -r requirement.txt
7
  ```
8
 
9
- ## Usage
10
- ```
11
- usage: pipeline.py [-h] [--link LINK] [--local_path LOCAL_PATH] [--download DOWNLOAD] [--result RESULT] [--video_name VIDEO_NAME] [--model_name]
12
 
13
- 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
  python3 pipeline.py --link https://www.youtube.com/watch?v=VrigMmXt9A0 --video_name Ukraine_and_its_Global_Impact
18
 
@@ -20,21 +25,30 @@ python3 pipeline.py --video_file '/home/jiaenliu/project-t/downloads/audio/Ukrai
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"
 
 
 
24
 
25
  options:
26
  -h, --help show this help message and exit
27
  --link LINK youtube video link here
28
- --local_path LOCAL_PATH
29
  local video path here
 
 
 
30
  --download DOWNLOAD download path
31
- --result RESULT translate result path
 
32
  --video_name VIDEO_NAME
33
- video name
34
- --model_name MODEL_NAME
35
- model name
 
 
 
36
 
 
37
  if you cannot download youtube video, please follow the link below.
38
- https://github.com/pytube/pytube/issues/1498
39
-
40
- ```
 
6
  pip install -r requirement.txt
7
  ```
8
 
9
+ ## Quick Start:
10
+
11
+ example online:
12
 
13
+ ```
14
+ python3 pipeline.py --link "https://www.youtube.com/watch?v=61c4dn6851g"
15
+ ```
16
 
17
+ example offline:
18
+ ```
19
+ python3 pipeline.py --audio_file test_translation.m4a --result ./results --video_name test_translation
20
+ ```
21
 
22
  python3 pipeline.py --link https://www.youtube.com/watch?v=VrigMmXt9A0 --video_name Ukraine_and_its_Global_Impact
23
 
 
25
 
26
  example offline: python3 pipeline.py --local_path test_translation.m4a --result ./results --video_name test_translation
27
 
28
+ ## Usage
29
+ ```
30
+ usage: pipeline.py [-h] [--link LINK] [--video_file VIDEO_FILE] [--audio_file AUDIO_FILE] [--srt_file SRT_FILE] [--download DOWNLOAD]
31
+ [--output_dir OUTPUT_DIR] [--video_name VIDEO_NAME] [--model_name MODEL_NAME] [-only_srt] [-v]
32
 
33
  options:
34
  -h, --help show this help message and exit
35
  --link LINK youtube video link here
36
+ --video_file VIDEO_FILE
37
  local video path here
38
+ --audio_file AUDIO_FILE
39
+ local audio path here
40
+ --srt_file SRT_FILE srt file input path here
41
  --download DOWNLOAD download path
42
+ --output_dir OUTPUT_DIR
43
+ translate result path
44
  --video_name VIDEO_NAME
45
+ video name, if use video link as input, the name will auto-filled by youtube video name
46
+ --model_name MODEL_NAME
47
+ model name only support text-davinci-003 and gpt-3.5-turbo
48
+ -only_srt set script output to only .srt file
49
+ -v auto encode script with video
50
+ ```
51
 
52
+ ## Notice
53
  if you cannot download youtube video, please follow the link below.
54
+ https://github.com/pytube/pytube/issues/1498
 
 
__pycache__/srt2ass.cpython-310.pyc DELETED
Binary file (13.9 kB)
 
pipeline.py CHANGED
@@ -2,9 +2,8 @@ import openai
2
  from pytube import YouTube
3
  import argparse
4
  import os
5
- import io
6
  import whisper
7
- import ffmpeg
8
 
9
  parser = argparse.ArgumentParser()
10
  parser.add_argument("--link", help="youtube video link here", default=None, type=str, required=False)
@@ -65,14 +64,12 @@ if args.link is not None and args.video_file is None:
65
  exit()
66
 
67
  video_path = f'{DOWNLOAD_PATH}/video/{video.default_filename}'
68
- # video_file = open(video_path, "rb")
69
  audio_path = '{}/audio/{}'.format(DOWNLOAD_PATH, audio.default_filename)
70
  audio_file = open(audio_path, "rb")
71
  if VIDEO_NAME == 'placeholder':
72
  VIDEO_NAME = audio.default_filename.split('.')[0]
73
  elif args.video_file is not None:
74
  # Read from local
75
- # video_file = open(args.video_file, "rb")
76
  video_path = args.video_file
77
  if args.audio_file is not None:
78
  audio_file= open(args.audio_file, "rb")
@@ -134,7 +131,7 @@ if script.strip():
134
  script_arr.append(script.strip())
135
 
136
  # Translate and save
137
- for s in script_arr:
138
  # using chatgpt model
139
  if model_name == "gpt-3.5-turbo":
140
  # print(s + "\n")
 
2
  from pytube import YouTube
3
  import argparse
4
  import os
 
5
  import whisper
6
+ from tqdm import tqdm
7
 
8
  parser = argparse.ArgumentParser()
9
  parser.add_argument("--link", help="youtube video link here", default=None, type=str, required=False)
 
64
  exit()
65
 
66
  video_path = f'{DOWNLOAD_PATH}/video/{video.default_filename}'
 
67
  audio_path = '{}/audio/{}'.format(DOWNLOAD_PATH, audio.default_filename)
68
  audio_file = open(audio_path, "rb")
69
  if VIDEO_NAME == 'placeholder':
70
  VIDEO_NAME = audio.default_filename.split('.')[0]
71
  elif args.video_file is not None:
72
  # Read from local
 
73
  video_path = args.video_file
74
  if args.audio_file is not None:
75
  audio_file= open(args.audio_file, "rb")
 
131
  script_arr.append(script.strip())
132
 
133
  # Translate and save
134
+ for s in tqdm(script_arr):
135
  # using chatgpt model
136
  if model_name == "gpt-3.5-turbo":
137
  # print(s + "\n")
placeholder.mp3 DELETED
Binary file (657 kB)