GithubHelp home page GithubHelp logo

adam-jimenez / auddit Goto Github PK

View Code? Open in Web Editor NEW
97.0 6.0 23.0 18.38 MB

Tired of those Reddit text-to-speech videos on Youtube? Now you can make your own!

Home Page: https://www.youtube.com/channel/UCMi63vc1Timv8dfrmcrrdFQ

License: MIT License

Python 100.00%

auddit's Introduction

Auddit

Tired of those Reddit text-to-speech videos on Youtube? Now you can make your own, automatically!

Official Auddit Youtube Channel: https://www.youtube.com/channel/UCMi63vc1Timv8dfrmcrrdFQ

thumbnail

Dependencies

Setup

sudo pip install -r requirements.txt

Then add the following environnement variables:

  • REDDIT_CLIENT_ID
  • REDDIT_CLIENT_SECRET

Read about how to create a Reddit application to get those.

You also need to register an application on the Google OAuthv2 API. Here's a guide. You need to put the resulting client_secrets.json in the root of the project.

Running

python src/main.py

Testing

All tests:

python -m unittest

Single test:

python -m unittest test/test_reddit.py

How it works

Using the Python Reddit API Wrapper, we can query for hot posts from any subreddit.

Then we pipe the text to the text-to-speech task, that generates an audio file using either ttsmp3.com or the Google TTS Python Wrapper. We prefer ttsmp3.com for the quality of the voices and use gTTS as a fallback if we get rate-limited.

Then, we send the text and the audio to the video generation tasks, which uses PyMovie to make a video with background music, the text-to-speech clips and the text.

Then we generate a thumbnail with the goal of clickbaiting the viewers with Pillow.

All that is left is to upload to Youtube using the Google API.

Why

because i can

auddit's People

Contributors

adam-jimenez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

auddit's Issues

File Not Found Error

Traceback (most recent call last):
File "C:\Users\Meridius\Desktop\redditbot\src\tasks\text_to_speech\task.py", line 24, in save_tts
with open(path, "wb") as out_file:
FileNotFoundError: [Errno 2] No such file or directory: '/data/audio/7aefc4c34d8c7f5f466a39ee63189bef.mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Meridius/Desktop/redditbot/src/main.py", line 28, in
pipeline.execute(subreddit='askreddit', nsfw=False, comment_limit=20)
File "C:/Users/Meridius/Desktop/redditbot/src/main.py", line 24, in execute
task(self.context)
File "C:\Users\Meridius\Desktop\redditbot\src\tasks\text_to_speech\task.py", line 39, in tts
post.title_audio = save_tts(post.title)
File "C:\Users\Meridius\Desktop\redditbot\src\tasks\text_to_speech\task.py", line 29, in save_tts
return save_gtts(text)
File "C:\Users\Meridius\Desktop\redditbot\src\tasks\text_to_speech\task.py", line 34, in save_gtts
tts.save(path)
File "C:\Users\Meridius\AppData\Local\Programs\Python\Python38-32\lib\site-packages\gtts\tts.py", line 294, in save
with open(str(savefile), 'wb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/data/audio/4472f828-99bd-4497-bf96-954e61731b50.mp3'

AttributeError: 'NoneType' object has no attribute 'name'

Traceback (most recent call last):
File "C:\Users\43650\Desktop\tttyt\auddit-master\src\main.py", line 30, in
pipeline.execute(subreddit='askreddit', nsfw=False, comment_limit=30)
File "C:\Users\43650\Desktop\tttyt\auddit-master\src\main.py", line 26, in execute
task(self.context)
File "C:\Users\43650\Desktop\tttyt\auddit-master\src\tasks\scrape_reddit\task.py", line 40, in get_hottest_post
comment_output.author = comment.author.name
AttributeError: 'NoneType' object has no attribute 'name'

i guess its cause of deletet comments but i am not good enough to fix it by myselfe

Post Duplicate Detection and Removal

Because people might repost the same answers in one single thread.

  • keyword-based (requires word vectors or some type of language model)
  • similarity-based (requires fuzzy-searching)

Client ID Error

Traceback (most recent call last):
File "C:/Users/Meridius/Desktop/auddit-master (1)/auddit-master/src/main.py", line 1, in
from tasks.scrape_reddit.task import get_hottest_post
File "C:\Users\Meridius\Desktop\auddit-master (1)\auddit-master\src\tasks\scrape_reddit\task.py", line 6, in
client_id = os.environ["MYKEYHERE"]
File "C:\Users\Meridius\AppData\Local\Programs\Python\Python38-32\lib\os.py", line 675, in getitem
raise KeyError(key) from None
KeyError: 'MYKEYHERE'

Error with MoviePy

Current Task: generate_video Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/moviepy/video/VideoClip.py", line 1168, in __init__ subprocess_call(cmd, logger=None) File "/usr/local/lib/python3.6/dist-packages/moviepy/tools.py", line 54, in subprocess_call raise IOError(err.decode('utf8')) OSError: convert: unable to read font Amiri-regular' @ warning/annotate.c/RenderType/960.
convert: delegate library support not built-in '/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1823.
convert: no decode delegate for this image format ' @ error/constitute.c/ReadImage/562. convert: no images defined PNG32:/tmp/tmpy1zr5as3.png' @ error/convert.c/ConvertImageCommand/3273.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "src/main.py", line 28, in
pipeline.execute(subreddit='askreddit', nsfw=False, comment_limit=20)
File "src/main.py", line 24, in execute
task(self.context)
File "/root/auddit/src/tasks/generate_video/task.py", line 62, in generate_video
clips.append(generate_title(post.title, post.title_audio))
File "/root/auddit/src/tasks/generate_video/task.py", line 20, in generate_title
txt_clip = TextClip(wrapped_text,fontsize=font_size, font=FONT, color=TITLE_FONT_COLOR, align="west")
File "/usr/local/lib/python3.6/dist-packages/moviepy/video/VideoClip.py", line 1177, in init
raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:

convert: unable to read font Amiri-regular' @ warning/annotate.c/RenderType/960. convert: delegate library support not built-in '/usr/share/fonts/type1/gsfonts/n019003l.pfb' (Freetype) @ warning/annotate.c/RenderFreetype/1823. convert: no decode delegate for this image format ' @ error/constitute.c/ReadImage/562.
convert: no images defined `PNG32:/tmp/tmpy1zr5as3.png' @ error/convert.c/ConvertImageCommand/3273.
.

.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect
`
I have ImageMagick installed and have tried various methods to fix. I have no idea what the issue is.

Generate_Video...Killed

Everything is going smooth, but then it starts the generate_video task, and after a few seconds it says Killed. The script is then interrupted. No error output or anything?

Use a couple of threads

Is there any way to use a couple of threads from a sub ?
Something like :
sub ->
5 best threads ->
10 best comments in every thread

Various errors

Hi, any advice on how I can fix the below errors. I am running Kali Linux as my OS. I have already set REDDIT_CLIENT_ID and REDDIT_CLIENT_SECRET using the export command in the terminal and confirming with echo.

┌──(kali㉿kali)-[~/Desktop/auddit]
└─$ python3 src/main.py         
Current Task: get_hottest_post
Current Task: tts
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
TTS Rate limit reached - Fallback on Google text-to-speech
Current Task: generate_video
Traceback (most recent call last):
  File "/home/kali/.local/lib/python3.9/site-packages/moviepy/video/VideoClip.py", line 1137, in __init__
    subprocess_call(cmd, logger=None)
  File "/home/kali/.local/lib/python3.9/site-packages/moviepy/tools.py", line 54, in subprocess_call
    raise IOError(err.decode('utf8'))
OSError: convert-im6.q16: attempt to perform an operation not allowed by the security policy `@/tmp/tmpw_lr5lrb.txt' @ error/property.c/InterpretImageProperties/3706.
convert-im6.q16: no images defined `PNG32:/tmp/tmp8rngpnz4.png' @ error/convert.c/ConvertImageCommand/3229.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kali/Desktop/auddit/src/main.py", line 28, in <module>
    pipeline.execute(subreddit='askreddit', nsfw=False, comment_limit=20)
  File "/home/kali/Desktop/auddit/src/main.py", line 24, in execute
    task(self.context)
  File "/home/kali/Desktop/auddit/src/tasks/generate_video/task.py", line 62, in generate_video
    clips.append(generate_title(post.title, post.title_audio))
  File "/home/kali/Desktop/auddit/src/tasks/generate_video/task.py", line 20, in generate_title
    txt_clip = TextClip(wrapped_text,fontsize=font_size, font=FONT, color=TITLE_FONT_COLOR, align="west")
  File "/home/kali/.local/lib/python3.9/site-packages/moviepy/video/VideoClip.py", line 1146, in __init__
    raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:

convert-im6.q16: attempt to perform an operation not allowed by the security policy `@/tmp/tmpw_lr5lrb.txt' @ error/property.c/InterpretImageProperties/3706.
convert-im6.q16: no images defined `PNG32:/tmp/tmp8rngpnz4.png' @ error/convert.c/ConvertImageCommand/3229.
.

.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect
                                                                                                                      
┌──(kali㉿kali)-[~/Desktop/auddit]
└─$                                

(I have no idea why it keeps saying ImageMagick is not installed as it definitely is!)

Any help is greatly appreciated.

Human Curation of content

Because crappy one-liner snarks that got bumped SHOULDN'T be included in the video.
And post-generation video snipping or editing is very inconvenient. Either:

  1. Each post are a separate video where you can stitch them together with ffmpeg
  2. There is a vetting function that allows you to pick posts before the video is generated

Error with reddit client id.

When running the reddit scrape test, I get an error that the client id is invalid. Does it take a certain amount of time for the client_id to get active or is something wrong? I have not written it wrong nor have I done any further changes in the script.

Index-based Comment Filtering and Selection

  • Comments with certain amount of points/upvotes
  • Comments with certain amount of replies (if it is too popular)
  • Comments by the original poster
  • Comments with posters of certain Karma or badges

Image Panorama

If the image is not in a normal format that can be fit in a 16:9 or 8:5 screen, and is "landscape" it should be in panorama mode, ideally based on information density of the image. However if it is portrait then it should at least show the image thumbnail before doing a top-to-bottom pan.

TODO: handle super long comments

If comments are too long they will overflow out of the frame, we should instead split the comment into multiple parts and display each part seperately

reddit client id throwing error

File "src/main.py", line 1, in
from tasks.scrape_reddit.task import get_hottest_post
File "/root/auddit/src/tasks/scrape_reddit/task.py", line 6, in
client_id = os.environ["Vgn2wHKB1iqKSQ"]
File "/usr/lib/python3.6/os.py", line 669, in getitem
raise KeyError(key) from None
KeyError: 'MY KEY IS RIGHT HERE'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.