-
Notifications
You must be signed in to change notification settings - Fork 1
/
master_translate.py
43 lines (31 loc) · 1.37 KB
/
master_translate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
from episode_scraper import EpisodeScraper
from aud_vid_recog import AudioVideoRecognizer
from text_recog import TextRecognizer
from subtitle_logging import log_init
##Created by Lex Whalen 2/19/21
class MasterTranslate():
###manages both text and speech recog
def __init__(self):
###standard paths
self.CWD = os.getcwd()
self.SUB_FOLDER = os.path.join(self.CWD,"generated_subs")
###for voice / text recog
self.AudVidRecog = AudioVideoRecognizer()
self.EpScraper = EpisodeScraper()
### used for logging
self.log = log_init(log_to_console=1)
def show_lang_options(self):
print("See the following link for all language codes:")
print("https://cloud.google.com/speech-to-text/docs/languages")
def scrape_show(self,src_lang,folder_path):
for num, f_name in enumerate(os.listdir(folder_path)):
f_path = os.path.join(folder_path,f_name)
text_path = os.path.join(self.SUB_FOLDER,"{}_sub{}".format(f_name.split(".")[0],num))
self.log.info("Scraping video path: %s", f_path)
self.EpScraper.scrape_episode(src_lang,f_path,out_path = text_path)
if __name__ == "__main__":
MT = MasterTranslate()
YOUR_LANG = "ja-JP"
YOUR_FLDR = "YOUR_SHOW_FLDR"
MT.scrape_show(YOUR_LANG,YOUR_FLDR)