Skip to content

Instantly share code, notes, and snippets.

@paxan
Last active December 26, 2015 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paxan/7189926 to your computer and use it in GitHub Desktop.
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.
#!/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