Created
December 6, 2019 14:45
-
-
Save aambrioso1/efa8d57bb567df78d1b7ec8a8e4dfb13 to your computer and use it in GitHub Desktop.
reader.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import re | |
from collections import Counter | |
import speech as sp | |
r = requests.get('http://www.gutenberg.org/cache/epub/5/pg5.txt') | |
txt = r.text | |
start = 'THE CONSTITUTION OF THE UNITED STATES OF AMERICA' | |
def words(text): return re.findall(r'\w+', text.lower()) | |
constitution = words(txt) | |
WORDS = Counter(constitution) | |
print(WORDS) | |
num = len(start) | |
num2 = 1000 | |
for i in range(3000): | |
if txt[i:i+num] == start: | |
num2 = i | |
print(txt[num2:num2 + 395]) | |
sp.say(txt[num2:num2 + 395], 'en-GB') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment