Last active
December 10, 2015 15:08
-
-
Save ChrisMorrisOrg/4452066 to your computer and use it in GitHub Desktop.
Given some text, this function will print out the text as if the computer is typing it live, in front of you.
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
def fakeChat(text): | |
# Set SPEED_VARIANCE to 0.001 for low variance, 10 for high variance | |
SPEED_VARIANCE = 0.1 | |
x = 0 | |
rate = 1 | |
# Ensure clean input | |
text = str(text) | |
rate = int(rate) | |
while x < len(text): | |
print(text[x:x+1], end="") | |
sys.stdout.flush() | |
sleep(random.random()*SPEED_VARIANCE) | |
x += rate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment