def sentencemaker(): # Use boolean to see if the user input is valid Bsen = False print("You can make sentences and choose what to eat here.") # Restraunt sentences loop while True: sentence = input( "what would you like to eat? Listen to the sentences closely after you choose\n" ) # checks if the input is valid if sentence in dic["SC2"]["EN"]: concat(["sounds/i_will_eat.wav", "sounds/" + sentence + ".wav"], "sounds/i_will_eat_" + sentence + ".wav") audio.play_file('sounds/i_will_eat_' + sentence + '.wav') # Sets boolean to true to show that user input is valid Bsen = True if sentence.lower() == "done": break if Bsen == False: print("Sorry, I don't know what that is, pick something else!") print("enter 'done' when you want to leave")
def death(self, why): clear() print(f'o noes!\nYou got killed by a {why}!') print(f'Score: {self.score}') audio.play_file('oof.mp3') input() sys.exit()
def speech(): speech_intro = "Create your sentence using words we have learnt so far!\n\n" #speech_help = "1.1. Time words: Yesterday/Today/Tomorrow/This morning/This evening\n1.2. Question: Who/Where 2. Verbs: I went/I will eat/I will go\n3. Misc words: Please pass the/and" # speech_intruction = "Use '+' sign to separate valid words, no space between '+' signs.\nEg. Today+I will eat+oranges\nType 'done' to go back to main menu\n" translations = open("translation.csv") available_words = [] for line in translations: data = line.split(",") available_words.append(data[1]) keep_creating_sentences = True while keep_creating_sentences: # print(speech_intro + speech_help + speech_intruction) print(speech_intro) user_speech = input("Now try creating a sentence yourself! ").lower( ).strip("!@,.? ").split("+") if user_speech == "done": replit.clear() keep_creating_sentences = False valid_sentence = False valid_words = 0 for words in user_speech: if words in available_words: valid_words += 1 if valid_words == len(user_speech): valid_sentence = True if valid_sentence: print("wuhu") outfile = '' for i in range(len(user_speech)): outfile += user_speech[i] outfile += '.wav' infiles = [] for word in user_speech: word += '.wav' new_word = 'sounds/' + word infiles.append(new_word) concat(infiles, outfile) audio.play_file(outfile) # os.remove(outfile) elif (not valid_sentence and keep_creating_sentences) or (not valid_words): print("Sorry, not valid sentense")
def fill_in_test(scene_name, scene_words): score = 0 for x in range(10): random_word = random.choice(list(scene_words)) audio.play_file("sounds/" + random_word + ".wav") choice = input("What is " + scene_words[random_word] + "? ").lower().strip("!?,. ") if choice == random_word: print("Good Job!") score += 1 else: print("Nope! it's", random_word) input("You got " + str(score) + "/10 right! Press <enter> ") return score
def test_other(self): source = audio.play_file(test_file) self.assertIsNotNone(source.end_time) self.assertIsNotNone(source.start_time) self.assertIsNotNone(source.remaining) source.paused = True time.sleep(1) self.assertEqual(source.paused, True, 'Pausing Source')
def learn(scene_name, learn_time): learn_first_time_intro = "Great, let's learn! Look around here and tell me a word in English.\nWhat do you want to learn the Blackfoot word for? Type it in English, or type done to finish. " learn_intro = "What do you want to learn the Blackfoot word for? " translations = open("translation.csv") scene_words = {} for line in translations: data = line.split(",") if data[0] == scene_name: scene_words[data[1]] = data[2].replace('\n', '') keep_learning = True while keep_learning: if learn_time == 0: eng_input = input(learn_first_time_intro + learn_intro).lower().strip("!?,. ") learn_time += 1 else: eng_input = input(learn_intro).lower().strip("!?,. ") valid_word = False for key, value in scene_words.items(): if eng_input == key: valid_word = True bf_output = value print(bf_output) audio.play_file("sounds/" + key + ".wav") sleep(3) elif eng_input == "done": replit.clear() keep_learning = False if valid_word: replit.clear() return learn(scene_name, learn_time) elif not valid_word and keep_learning: print("Sorry, I don't know that one. Try another word!") sleep(2) replit.clear()
def test_loop_setting(self): source = audio.play_file(test_file) self.assertEqual(source.loops_remaining, 0, '0 loops remaining') source.set_loop(2) time.sleep(1) self.assertEqual(source.loops_remaining, 2, '2 loops remaining') source.paused = True time.sleep(1) self.assertEqual(source.paused, True, 'Pausing Source')
def learn(SC): print( "Great, let's learn! Look around here and tell me a word in English.") # learn loop while True: learning = input( "What do you want to learn the Blackfoot word for? When you're done, type done \n" ) # Use boolean to see if the user input is valid when compared with the list of translation words A = False # x is used to help index the dictionary x = 0 # Checks each row in the .csv file for the user input, if the user input is in the .csv file, the translated word is printed and the corresponding audio file is played for i in dic[SC]["EN"]: if learning.lower() == i.lower(): print(dic[SC]["BF"][x]) # replace() and strip() are used so they don't interfere with finding the audio file Input = learning.replace(" ", "_").strip("?!").replace( "'", "").replace(".", "").lower() audio.play_file('sounds/' + Input + '.wav') # Sets boolean to true to show that user input is valid A = True x += 1 # BREAK for town learn loop if learning.lower() == "done": break # if the user enters a inproper input if A == False: print("Sorry, I don't know that one. Try another word!")
def test_pause(self): source = audio.play_file(test_file) source.volume = 2 time.sleep(1) self.assertEqual(source.volume, 2, "Volume set to 2") source.paused = True time.sleep(1) self.assertEqual(source.paused, True, 'Pausing Source') source.volume = .2 time.sleep(1) self.assertEqual(source.volume, .2, 'Volume set to .2') source.paused = True time.sleep(1) self.assertEqual(source.paused, True, 'Pausing Source')
def test_creation(self): source = audio.play_file(test_file) self.assertEqual(source.path, test_file) source.paused = True time.sleep(1) self.assertEqual(source.paused, True, 'Pausing Source')
playerturndone = False comturndone = False randomluckmode = False if playornoplay == "yes": time.sleep(1) os.system("clear") #This means the game will run print("then lets play!\n") #Game rules source = audio.play_file("rules song.mp3") print("Here is how to play this game:\n") print("there will be six cards you can only pick 3 and the com player will pick 3\n") print("you pick the three cards and win by luck. you might have good luck meaning you win\n") print("or you have bad luck and you lose!\n") print("press key 1 to 6 to choose a card for each turn you get and then press enter\n") print("when you select one card you can't use it again.\n") print("For example. you use 3rd card as first card, you can't use it again nor the com use it\n") #This is to see if the player understands the rules print("Now do you understand the rules and do you want to start the game?\n") request = input("Yes or No?\n") if request == "Yes" or "yes":
def play_game(term, difficulty): global board board = [] for letter in term: if letter == ' ': board.append(' ') else: board.append('-') guesses = [] num_reveals = 0 num_wrong = 0 no_reveals = False if difficulty == '1': max_num_wrong = 7 display_hangman_2(num_wrong) elif difficulty == '2': max_num_wrong = 6 display_hangman_1(num_wrong) display_board() while num_wrong < max_num_wrong: if '-' not in board: print('Sorry you lose.') display_menu() p1_input = (input('Guess a letter ')).lower() while p1_input.isalpha() == False or len(p1_input) > 1: print('Enter one lowercase alphabetical letter.') display_board() p1_input = (input('Guess a letter ')).lower() else: letters = [] for i in term: letters.append(i) if p1_input in term: audio.play_file("correct_answer.wav") if p1_input not in guesses: guesses.append(p1_input) no_reveals = True if term.count(p1_input) > 1: repeated_indices = duplicates(letters, p1_input) for index in repeated_indices: board[index] = p1_input else: go_to = term.index(p1_input) board[go_to] = p1_input else: num_wrong += 1 audio.play_file("wrong_answer.wav") no_reveals = False if difficulty == '1': display_hangman_2(num_wrong) elif difficulty == '2': display_hangman_1(num_wrong) display_board() if '-' not in board: print('\n You got it!') display_menu() else: if num_wrong == max_num_wrong or '-' not in board: print('\n The term was: ' + term) print('\n Sorry you lose.') display_menu() if difficulty == '1' and num_wrong == 5: if len(term) < 5: num_reveals = 1 elif len(term) > 5 and len(term) < 10: num_reveals = 2 elif len(term) > 10: num_reveals = 2 if difficulty == '2' and num_wrong == 4: if len(term) < 5: num_reveals = 0 elif len(term) >= 5 and len(term) < 10: num_reveals = 1 elif len(term) >= 10: num_reveals = 2 if num_reveals != 0 and no_reveals != True: reveal = random.randint(0, len(term) - 1) while board[reveal] != '-': reveal = random.randint(0, len(term) - 1) if term.count(term[reveal]) > 1: repeated_indices = duplicates(letters, term[reveal]) for index in repeated_indices: board[index] = term[reveal] else: board[reveal] = term[reveal] display_board() print("< Here's a hint") num_reveals -= 1 return
import random from replit import audio genre = input( "1. Meglovania \n2. Gas Gas Gas\n3. DejaVu \n4. Running in the 90s\n5. Pigstep\n6. Never Gonna Give You Up\n Select your Music:" ) if genre == "1": source = audio.play_file('Meglovania.mp3') print("Now Playing Meglovania, by Undertale. Enjoy Your Game!") if genre == "2": source = audio.play_file('Gas.mp3') print("Now Playing Gas Gas Gas, by Initial D. Enjoy Your Game!") if genre == "3": source = audio.play_file('DejaVu.mp3') print("Now Playing Deja Vu, by Initial D. Enjoy Your Game") if genre == "4": source = audio.play_file('Running.mp3') print( "Now Playing Running in the 90s, by Maurizio De Jorios. Enjoy Your Game!" ) if genre == "5":
def play_sound(file): audio.play_file(file)