├── LICENSE ├── README ├── README.md ├── Script.xmind ├── app.py ├── audio.py ├── chromedriver ├── final_movie.mp4 ├── googleImage.py ├── make.py ├── req.py ├── text.mp3 ├── text.txt └── thumb.jpeg /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Auto-Bot-Channel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | Made by Vaibhav Singh 24 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Auto-bot-Channel/text-to-video/abacbd5575b586cae5c7bd47dd78c6645c1a9241/README -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Text to Video 2 | 3 | ## To setup and run 4 | just clone the project and open text.txt file and add the text you want to make video, And run 5 | ``` 6 | ~$ python3 app.py 7 | ``` 8 | **Watch on youtube!!** 9 | [![Video link](thumb.jpeg)](https://www.youtube.com/watch?v=KAmYMtVasnI) 10 | 11 | ## MIT License 12 | 13 | [MIT](LICENSE) 14 | #### Copyright (c) 2020 [Auto-Bot-Channel](https://www.youtube.com/channel/UCwNJ7sohzMH4DvXHRE1aANg) 15 | #### Made by [Vaibhav Singh](https://github.com/itsvaibhav01) 16 | -------------------------------------------------------------------------------- /Script.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Auto-bot-Channel/text-to-video/abacbd5575b586cae5c7bd47dd78c6645c1a9241/Script.xmind -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | 4 | os.system('python3 audio.py') 5 | time.sleep(1) 6 | print('audio file made') 7 | os.system('python3 req.py') 8 | time.sleep(1) 9 | print('alligned files') 10 | os.system('python3 make.py') 11 | time.sleep(1) 12 | 13 | os.system('rm -r downl outd') 14 | time.sleep(1) 15 | os.system('rm output.mp4 list.txt') -------------------------------------------------------------------------------- /audio.py: -------------------------------------------------------------------------------- 1 | from gtts import gTTS 2 | 3 | 4 | text = open('text.txt') 5 | story = "" 6 | for lines in text: 7 | story += lines 8 | 9 | myobj = gTTS(text=story, lang='en', slow=False) 10 | myobj.save("text.mp3") -------------------------------------------------------------------------------- /chromedriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Auto-bot-Channel/text-to-video/abacbd5575b586cae5c7bd47dd78c6645c1a9241/chromedriver -------------------------------------------------------------------------------- /final_movie.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Auto-bot-Channel/text-to-video/abacbd5575b586cae5c7bd47dd78c6645c1a9241/final_movie.mp4 -------------------------------------------------------------------------------- /googleImage.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | import time 3 | import requests 4 | import urllib.request 5 | import os 6 | from PIL import Image 7 | from selenium.webdriver.common.keys import Keys 8 | from selenium.webdriver.chrome.options import Options 9 | 10 | 11 | class GoogleImage(): 12 | def __init__(self, head = True): 13 | 14 | chrome_options = Options() 15 | os.system('mkdir downl') 16 | 17 | if not head: 18 | chrome_options.add_argument("--headless") 19 | 20 | self.browser = webdriver.Chrome("./chromedriver", options=chrome_options) 21 | 22 | def getImg(self, name, count): 23 | 24 | c = 1 25 | done = False 26 | 27 | while not done: 28 | try: 29 | self.browser.get("https://www.google.com/imghp?hl=EN") 30 | time.sleep(3) 31 | s = self.browser.find_element_by_name('q') 32 | 33 | s.send_keys(f'"{name}" word') 34 | s.send_keys(Keys.ENTER) 35 | 36 | self.browser.find_element_by_xpath(f'/html/body/div[2]/c-wiz/div[3]/div[1]/div/div/div/div/div[1]/div[1]/div[{c}]/a[1]/div[1]/img').click() 37 | time.sleep(3) 38 | 39 | self.i = self.browser.find_element_by_xpath('/html/body/div[2]/c-wiz/div[3]/div[2]/div[3]/div/div/div[3]/div[2]/c-wiz/div[1]/div[1]/div/div[2]/a/img') 40 | src = self.i.get_attribute('src') 41 | 42 | image = Image.open(urllib.request.urlopen(src)) 43 | 44 | width, height = image.size 45 | print(width,height) 46 | 47 | if width < 900 and height < 600: 48 | raise Exception('Image size not enough') 49 | 50 | 51 | urllib.request.urlretrieve(src, os.path.join('downl','i'+ str(count) + '.jpg')) 52 | done = True 53 | except: 54 | c+=1 55 | 56 | def close(self): 57 | self.browser.quit() -------------------------------------------------------------------------------- /make.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | 4 | os.system('ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4') 5 | time.sleep(3) 6 | os.system('ffmpeg -i output.mp4 -i text.mp3 -c:v copy -c:a aac final_movie.mp4') 7 | time.sleep(3) 8 | print('final_movie.mp4 FINISHED') -------------------------------------------------------------------------------- /req.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from googleImage import GoogleImage 3 | import os 4 | import time 5 | 6 | def filt(w): 7 | n = max([w.find('<'), w.find('>'),w.find('-')]) 8 | m = len(w) < 4 9 | print(n,m) 10 | if n != -1 or m == True: 11 | return True 12 | return False 13 | 14 | 15 | params = ( 16 | ('async', 'false'), 17 | ) 18 | 19 | files = { 20 | 'audio': ('text.mp3', open('text.mp3', 'rb')), 21 | 'transcript': ('text.txt', open('text.txt', 'rb')), 22 | } 23 | 24 | r = requests.post('http://gentle-demo.lowerquality.com/transcriptions', params=params, files=files) 25 | r = r.json() 26 | 27 | data = [] 28 | last = 0 29 | 30 | for x in r['words']: 31 | try: 32 | if not filt(x['alignedWord']): 33 | data.append([x['alignedWord'] , 1/(x['end']-last) ]) 34 | last = x['end'] 35 | except: 36 | pass 37 | 38 | Img = GoogleImage() 39 | listf = open("list.txt", "w") 40 | os.system('mkdir outd') 41 | 42 | print(data) 43 | 44 | count = 1 45 | for x,_ in data: 46 | Img.getImg(name=x, count=count) 47 | listf.write(f"file './outd/out{count}.mp4'\n") 48 | count +=1 49 | listf.close 50 | Img.close() 51 | 52 | for x in range(1,len(data)+1): 53 | os.system(f'ffmpeg -framerate {data[x-1][1]} -i ./downl/i{x}.jpg -s 1280x720 -r 30 -pix_fmt yuv420p ./outd/out{x}.mp4') 54 | time.sleep(0.1) 55 | 56 | time.sleep(1) 57 | -------------------------------------------------------------------------------- /text.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Auto-bot-Channel/text-to-video/abacbd5575b586cae5c7bd47dd78c6645c1a9241/text.mp3 -------------------------------------------------------------------------------- /text.txt: -------------------------------------------------------------------------------- 1 | This Video was made by Automated python application. 2 | Please like share subscribe to my channel. -------------------------------------------------------------------------------- /thumb.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Auto-bot-Channel/text-to-video/abacbd5575b586cae5c7bd47dd78c6645c1a9241/thumb.jpeg --------------------------------------------------------------------------------