Created
February 10, 2025 22:15
-
-
Save se7enack/1da58c8abf6caae726f672d0ad59496a to your computer and use it in GitHub Desktop.
Revisions
-
se7enack created this gist
Feb 10, 2025 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ #!/usr/bin/env python3 import csv from random import randrange import time import pyttsx3 def countdown(t): while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) t -= 1 def game(): rowz = 0 rowcount = 0 for row in open("trivia.csv"): rowcount += 1 with open("trivia.csv", "r") as f: reader = csv.reader(f) header = next(reader) for row in reader: z = len(row[0]) if rowz == randrange(rowcount): return row count = 0 while count <= 5: x = None while x is None: try: engine = pyttsx3.init(driverName='nsss') x = game() print(f"\n\n{x[0]}") engine.say(x[0]) engine.runAndWait() countdown(int(7)) print(f"{x[1]}\n") engine.say(x[1]) engine.runAndWait() count += 1 time.sleep(2) except: pass