Last active
December 26, 2015 17:49
-
-
Save paxan/7189926 to your computer and use it in GitHub Desktop.
Says numbers of Fibonacci sequence starting from the 50th one and goes on forever.
This file contains 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
#!/usr/bin/env python | |
from __future__ import print_function | |
import random | |
import time | |
from subprocess import check_call | |
from shlex import split | |
voices = tuple('Agnes Kathy Princess Vicki Victoria Bruce Fred Junior Ralph'.split()) + \ | |
tuple('Albert Bahh Bells Boing Bubbles Cellos Deranged Hysterical Trinoids Whisper Zarvox'.split()) + \ | |
("Bad News", "Good News", "Pipe Organ") | |
def say(text): | |
voice = random.choice(voices) | |
print('{}: {}'.format(voice, text)) | |
check_call(split('say -v "{}" "{}"'.format(voice, text))) | |
def fibg(a, b): | |
while True: | |
a, b = b, a + b | |
yield b | |
def fibs(): | |
yield 0 | |
yield 1 | |
for f in fibg(0, 1): | |
yield f | |
for i, f in enumerate(fibs()): | |
if i > 50: | |
say(f) | |
time.sleep(1.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment