Skip to content

Instantly share code, notes, and snippets.

@aambrioso1
Created December 6, 2019 14:45
Show Gist options
  • Save aambrioso1/efa8d57bb567df78d1b7ec8a8e4dfb13 to your computer and use it in GitHub Desktop.
Save aambrioso1/efa8d57bb567df78d1b7ec8a8e4dfb13 to your computer and use it in GitHub Desktop.
reader.py
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