diff --git a/madlibs/badCurrentStory.mp3 b/madlibs/badCurrentStory.mp3 index a97a560..ec092ae 100644 Binary files a/madlibs/badCurrentStory.mp3 and b/madlibs/badCurrentStory.mp3 differ diff --git a/madlibs/badCurrentTTS.mp3 b/madlibs/badCurrentTTS.mp3 index 49640b2..da0ce6c 100644 Binary files a/madlibs/badCurrentTTS.mp3 and b/madlibs/badCurrentTTS.mp3 differ diff --git a/madlibs/currentTTS.mp3 b/madlibs/currentTTS.wav similarity index 56% rename from madlibs/currentTTS.mp3 rename to madlibs/currentTTS.wav index c55ab75..61f2262 100644 Binary files a/madlibs/currentTTS.mp3 and b/madlibs/currentTTS.wav differ diff --git a/madlibs/madlibsDiscord.py b/madlibs/madlibsDiscord.py index d8b1b0e..a27de7d 100755 --- a/madlibs/madlibsDiscord.py +++ b/madlibs/madlibsDiscord.py @@ -2,7 +2,7 @@ # Toggle me for debugging debug = 1 # Displays warning message -testing = 0 +testing = 1 # Import the libraries we will use #from mega import Mega from datetime import datetime @@ -17,7 +17,9 @@ import ffmpeg #import talkey async def gameLoop(): - #Init tts, and connect voice to channel, hackily reinit connection if broken + # In the future we will detect what channel we were summoned in, but for now: + ativeChannel = 656233549837631508 + #Init tts, and connect voice to channel, reinit connection if broken voiceChannel = client.get_channel(682688245964079127) voice = await voiceChannel.connect() if voice.is_connected() == True: @@ -76,30 +78,38 @@ async def gameLoop(): # Run a loop to get the words replaceList = [] - #replaceList =['', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24'] + #replaceList =['', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24'] replaceList.append("") await channel.send(str("Type a noun, verb, adjective, or adverb depending on what it asks you, followed by enter.")) for loopCount in range(replacedNumber): + print("Times looped: "+str(loopCount)) #Wait for user to reply await channel.send("Give me a(n) "+"**"+str(filtered[loopCount])+"**"+": ") + #if we see our own message, ignore it + async def on_message(message): + if message.author == self.user: + return + #if we see a message in a channel that isn't in the active one, ignore it + if message.channel.id != activeChannelID: + return # Push text to gTTS and save it to a file tts = gTTS(text="Give me a(n) "+str(filtered[loopCount])+": ") os.system("rm badCurrentTTS.mp3") - os.system("rm currentTTS.mp3") + os.system("rm currentTTS.wav") tts.save("badCurrentTTS.mp3") # gTTS is stupid and gives us a file that discord.py doesn't understand, so we have to convert it ( ffmpeg .input('badCurrentTTS.mp3') - .output('currentTTS.mp3', audio_bitrate=48000, format='wav', sample_fmt='s16', ac='2') + .output('currentTTS.wav', audio_bitrate=48000, format='wav', sample_fmt='s16', ac='2') .run() ) if voice.is_playing() == True: print("Audio is playing! Stopping playback!"+'\n') voice.stop() print("Attempting to play audio"+'\n') - voice.play(discord.FFmpegPCMAudio("currentTTS.mp3")) + voice.play(discord.FFmpegPCMAudio("currentTTS.wav")) raw_message = await client.wait_for('message') replaceVar = raw_message.content print("You gave me: "+replaceVar) @@ -131,22 +141,22 @@ async def gameLoop(): # Send Story to Discord await channel.send(generatedStory) await channel.send("Processing TTS, please wait!") - tts = gTTS(text=generatedStory+"This story was generated by Caleb Fontenot's MadLibs.py", lang='en') - os.system("rm badCurrentStory.mp3") - tts.save("badCurrentStory.mp3") - # gTTS is stupid and gives us a file that discord.py doesn't understand, so we have to convert it - ( - ffmpeg - .input('badCurrentStory.mp3') - .output(saveFile+'.mp3', audio_bitrate=48000, format='wav', sample_fmt='s16', ac='2') - .run() - ) - if voice.is_playing() == True: - print("Audio is playing! Stopping playback!"+'\n') + async with channel.typing(): + tts = gTTS(text=generatedStory+"This story was generated by CCF_100's MadLibs.py", lang='en') + os.system("rm badCurrentStory.mp3") + tts.save("badCurrentStory.mp3") + # gTTS is stupid and gives us a file that discord.py doesn't understand, so we have to convert it + ( + ffmpeg + .input('badCurrentStory.mp3') + .output(saveFile+'.mp3', audio_bitrate=48000, format='wav', sample_fmt='s16', ac='2') + .run() + ) + if voice.is_playing() == True: + print("Audio is playing! Stopping playback!"+'\n') voice.stop() - print("Attempting to play audio"+'\n') - voice.play(discord.FFmpegPCMAudio(saveFile+".mp3")) - + print("Attempting to play audio"+'\n') + voice.play(discord.FFmpegPCMAudio(saveFile+".mp3")) #exit() #Alright! We're done! Let's save the story to a file if os.path.exists("saved stories"): @@ -157,10 +167,8 @@ async def gameLoop(): await channel.send("Saving story to .txt file") async with channel.typing(): file = open(saveFile+'.txt', 'w+') - line_offset = [] offset = 0 - for line in file: line_offset.append(offset) offset += len(line) @@ -174,19 +182,19 @@ async def gameLoop(): discordFile = discord.File(saveFile+'.txt', filename="generatedStory.txt") await channel.send(file=discordFile) #Send generated .mp3 file to Discord - #If file is above 8 MB, upload it to MEGA mp3File = saveFile+'.mp3' - def file_size(mp3File): - statinfo = os.stat(mp3File) + def file_size(fname): + statinfo = os.stat(fname) return statinfo.st_size - echo("MP3 is "+file_size+" bytes.") - await channel.send("MP3 is "+file_size+" bytes." - if int(file_size) <= int(8389999): + print("MP3 is "+str(file_size(mp3File))+" bytes.") + await channel.send("Converted WAV is "+str(file_size(mp3File))+" bytes.") + if int(file_size(mp3File)) <= int(8389999): # File is over 8 MiB! This will fail if we send the file corrected for transmission via Discord's voice chat. Let's send the original instead. - discordFile = discord.File(badCurrentStory.mp3, filename=saveFile+'.mp3') + discordFile = discord.File("badCurrentStory.mp3", filename=saveFile+'.mp3') + await channel.send(file=discordFile) + else: + discordFile = discord.File(saveFile+'.wav', filename=saveFile+'.wav') await channel.send(file=discordFile) - discordFile = discord.File(saveFile+'.mp3', filename=saveFile+'.mp3') - await channel.send(file=discordFile) #Setup Discord functions and announce on discord that we are ready @@ -205,14 +213,18 @@ class MyClient(discord.Client): channel = client.get_channel(656233549837631508) await gameLoop() await channel.send("Done!") + #Disconnect Voice + await asyncio.sleep(60) + voiceChannel = client.get_channel(682688245964079127) await voice.disconnect() - #Run main Game loop # The Discord bot ID isn't stored in this script for security reasons, so we have to go get it f = open('botID.txt', 'r') BotID = f.read() - +#Cleanup from previous session +#os.system("rm badCurrentTTS.mp3") +#os.system("rm currentTTS.wav") # Connect Bot To Discord and start running client = MyClient() client.run(BotID) diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:11:47.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-19:11:47.mp3 new file mode 100644 index 0000000..ce4df06 Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-19:11:47.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:11:47.txt b/madlibs/saved stories/generatedStory-27-02-2020-19:11:47.txt new file mode 100644 index 0000000..ba96c07 --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-19:11:47.txt @@ -0,0 +1,5 @@ +Awards Show + +Welcome everyone to asdf and the asdf MadLib awards show. Here are the nominees for asdf. First, sadf. Next, asdf. And finally, asdf. And the winner is... asdf! asdf could not be here tonight so he recorded a message for us to see. Take a look. Winner: Hello all. Thank you, the fans, for voting. I really appreciate it. I am sorry I couldn't be there. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:14:17.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-19:14:17.mp3 new file mode 100644 index 0000000..8a30cae Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-19:14:17.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:14:17.txt b/madlibs/saved stories/generatedStory-27-02-2020-19:14:17.txt new file mode 100644 index 0000000..39f48ec --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-19:14:17.txt @@ -0,0 +1,5 @@ +MadLib Gameshow + +asdf on down! You're the next contestant on asdf's new gameshow, MadLib! Here's how it works. You will sadf over a asdf at a rate of asdf mph. After you jump over that item, you will g over to the l l and press the l at the end. l time wins! Oh. I forgot to introduce our host. He's a l person who can't wait to l in to the show. Please welcome, l! Alright players, on your mark. Get set. l! Alright, here goes l on the first stage of the competition. And.. WOAH! He just l over the thing! That's gonna hurt him tommorow. But it'll be all worth it after he wins the grand prize of l dollars! Which he says will go towards l. Very l investment, but it's his money! Here he comes around the second leg. AND WOAH, AGAIN HE LOOKS l ON NETWORK TELEVISION! This is what primetime is all about here on the network of k. And, he presses it! He finishes with a time of l. Will that be enough to win? Find out on l when l will challenge him for the grand prize. For all of us here at MadLib, good night everyone! + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:17:21.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-19:17:21.mp3 new file mode 100644 index 0000000..e156ed6 Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-19:17:21.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:17:21.txt b/madlibs/saved stories/generatedStory-27-02-2020-19:17:21.txt new file mode 100644 index 0000000..ccbbfff --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-19:17:21.txt @@ -0,0 +1,5 @@ +Three Little Pigs + +Once upon a time, there were three l pigs. One day, their mother said, "You are all grown up and must l on your own." So they left to l their houses. The first little pig wanted only to l all day and quickly built his house out of l. The second little pig wanted to l and l all day so he l his house with l. The third l pig knew the wolf lived nearby and worked hard to l his house out of l. One day, the wolf knocked on the first pig's l. "Let me in or I'll l your house down!" The pig didn't, so the wolf l down the l. The wolf knocked on the second pig's l. "Let me in or I'll blow your l down!" The pig didn't, so the wolf l down the house. Then the wolf knocked on the third l pig's door. "Let me in or I'll blow your house down!" The little pig didn't, so the wolf l and l.He could not blow the house down. All the pigs went to live in the l house and they all l happily ever after. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:20:28.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-19:20:28.mp3 new file mode 100644 index 0000000..d045ae7 Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-19:20:28.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:20:28.txt b/madlibs/saved stories/generatedStory-27-02-2020-19:20:28.txt new file mode 100644 index 0000000..ff2f7ee --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-19:20:28.txt @@ -0,0 +1,5 @@ +Three Little Pigs + +Once upon a time, there were three l pigs. One day, their mother said, "You are all grown up and must l on your own." So they left to l their houses. The first little pig wanted only to l all day and quickly built his house out of l. The second little pig wanted to l and l all day so he Give me a(n) **past tense verb**: his house with l. The third l pig knew the wolf lived nearby and worked hard to l his house out of l. One day, the wolf knocked on the first pig's l. "Let me in or I'll l your house down!" The pig didn't, so the wolf l down the l. The wolf knocked on the second pig's l. "Let me in or I'll blow your l down!" The pig didn't, so the wolf l down the house. Then the wolf knocked on the third l pig's door. "Let me in or I'll blow your house down!" The little pig didn't, so the wolf l and l.He could not blow the house down. All the pigs went to live in the l house and they all l happily ever after. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:30:47.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-19:30:47.mp3 new file mode 100644 index 0000000..d74559f Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-19:30:47.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:30:47.txt b/madlibs/saved stories/generatedStory-27-02-2020-19:30:47.txt new file mode 100644 index 0000000..4d15784 --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-19:30:47.txt @@ -0,0 +1,5 @@ +AMC Cinemas Pre-Show Policy + +Thank you for choosing AMC Cinemas. Where we make movie moments AMC l. Your safety is l to us, so remember, keep a l on your valuables. Be sure to report any l behavior. And please take a moment to find any emergency exits near you. Make sure to stock up on l and l at the concessions bar. Enjoy your movie, l and we thank you for choosing AMC Cinemas as your destination to watch that movie. Please, silence your l now and be quiet and courteous of your peers. And now, ladies and gentlemen, here are some special previews coming to an AMC near you. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:36:50.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-19:36:50.mp3 new file mode 100644 index 0000000..f8c8e06 Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-19:36:50.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:36:50.txt b/madlibs/saved stories/generatedStory-27-02-2020-19:36:50.txt new file mode 100644 index 0000000..0de75ab --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-19:36:50.txt @@ -0,0 +1,5 @@ +Three Little Pigs + +Once upon a time, there were three asdf pigs. One day, their mother said, "You are all grown up and must asdf on your own." So they left to l their houses. The first little pig wanted only to l all day and quickly built his house out of l. The second little pig wanted to l and l all day so he l his house with l. The third l pig knew the wolf lived nearby and worked hard to l his house out of l. One day, the wolf knocked on the first pig's Give me a(n) **noun**:. "Let me in or I'll l your house down!" The pig didn't, so the wolf l down the l. The wolf knocked on the second pig's l. "Let me in or I'll blow your l down!" The pig didn't, so the wolf l down the house. Then the wolf knocked on the third pig's door. "Let me in or I'll blow your house down!" The little pig didn't, so the wolf l and l.He could not blow the house down. All the pigs went to live in the l house and they all l happily ever after. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:39:25.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-19:39:25.mp3 new file mode 100644 index 0000000..d74559f Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-19:39:25.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:39:25.txt b/madlibs/saved stories/generatedStory-27-02-2020-19:39:25.txt new file mode 100644 index 0000000..4d15784 --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-19:39:25.txt @@ -0,0 +1,5 @@ +AMC Cinemas Pre-Show Policy + +Thank you for choosing AMC Cinemas. Where we make movie moments AMC l. Your safety is l to us, so remember, keep a l on your valuables. Be sure to report any l behavior. And please take a moment to find any emergency exits near you. Make sure to stock up on l and l at the concessions bar. Enjoy your movie, l and we thank you for choosing AMC Cinemas as your destination to watch that movie. Please, silence your l now and be quiet and courteous of your peers. And now, ladies and gentlemen, here are some special previews coming to an AMC near you. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:41:38.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-19:41:38.mp3 new file mode 100644 index 0000000..d8a8f48 Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-19:41:38.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-19:41:38.txt b/madlibs/saved stories/generatedStory-27-02-2020-19:41:38.txt new file mode 100644 index 0000000..499e32a --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-19:41:38.txt @@ -0,0 +1,5 @@ +Three Little Pigs + +Once upon a time, there were three l pigs. One day, their mother said, "You are all grown up and must l on your own." So they left to l their houses. The first little pig wanted only to l all day and quickly built his house out of l. The second little pig wanted to l and Give me a(n) **verb**: all day so he l his house with l. The third l pig knew the wolf lived nearby and worked hard to l his house out of l. One day, the wolf knocked on the first pig's l. "Let me in or I'll l your house down!" The pig didn't, so the wolf l down the l. The wolf knocked on the second pig's l. "Let me in or I'll blow your l down!" The pig didn't, so the wolf l down the house. Then the wolf knocked on the third l pig's door. "Let me in or I'll blow your house down!" The little pig didn't, so the wolf and l.He could not blow the house down. All the pigs went to live in the l house and they all l happily ever after. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-20:01:47.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-20:01:47.mp3 new file mode 100644 index 0000000..0ea0e64 Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-20:01:47.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-20:01:47.txt b/madlibs/saved stories/generatedStory-27-02-2020-20:01:47.txt new file mode 100644 index 0000000..70eb5f2 --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-20:01:47.txt @@ -0,0 +1,5 @@ +Three Little Pigs + +Once upon a time, there were three l pigs. One day, their mother said, "You are all grown up and must l on your own." So they left to l their houses. The first little pig wanted only to l all day and quickly built his house out of Give me a(n) **plural noun**:. The second little pig wanted to l and l all day so he l his house with l. The third l pig knew the wolf lived nearby and worked hard to l his house out of k. One day, the wolf knocked on the first pig's f. "Let me in or I'll a your house down!" The pig didn't, so the wolf e down the v. The wolf knocked on the second pig's q. "Let me in or I'll blow your w down!" The pig didn't, so the wolf r down the house. Then the wolf knocked on the third t pig's door. "Let me in or I'll blow your house down!" The little pig didn't, so the wolf k and l.He could not blow the house down. All the pigs went to live in the l house and they all l happily ever after. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-20:09:39.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-20:09:39.mp3 new file mode 100644 index 0000000..09ff768 Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-20:09:39.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-20:09:39.txt b/madlibs/saved stories/generatedStory-27-02-2020-20:09:39.txt new file mode 100644 index 0000000..1ce728f --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-20:09:39.txt @@ -0,0 +1,5 @@ +AMC Cinemas Pre-Show Policy + +Thank you for choosing AMC Cinemas. Where we make movie moments AMC running. Your safety is strange to us, so remember, keep a knuckles on your valuables. Be sure to report any odd behavior. And please take a moment to find any emergency exits near you. Make sure to stock up on Sparkling Ice and Pizza at the concessions bar. Enjoy your movie, and we thank you for choosing AMC Cinemas as your destination to watch that movie. Please, silence your asdf now and be quiet and courteous of your peers. And now, ladies and gentlemen, here are some special previews coming to an AMC near you. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-21:09:29.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-21:09:29.mp3 new file mode 100644 index 0000000..feb9775 Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-21:09:29.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-21:09:29.txt b/madlibs/saved stories/generatedStory-27-02-2020-21:09:29.txt new file mode 100644 index 0000000..c7d2025 --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-21:09:29.txt @@ -0,0 +1,5 @@ +Awards Show + +Welcome everyone to Jerusalem and the 2473 MadLib awards show. Here are the nominees for idklol. First, Barack Obama. Next, Kate Mulgrew. And finally, Donald Trump. And the winner is... Kate Mulgrew! could not be here tonight so he recorded a message for us to see. Take a look. Winner: Hello all. Thank you, the fans, for voting. I really appreciate it. I am sorry I couldn't be there. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file diff --git a/madlibs/saved stories/generatedStory-27-02-2020-21:32:20.mp3 b/madlibs/saved stories/generatedStory-27-02-2020-21:32:20.mp3 new file mode 100644 index 0000000..fbc5edf Binary files /dev/null and b/madlibs/saved stories/generatedStory-27-02-2020-21:32:20.mp3 differ diff --git a/madlibs/saved stories/generatedStory-27-02-2020-21:32:20.txt b/madlibs/saved stories/generatedStory-27-02-2020-21:32:20.txt new file mode 100644 index 0000000..3d86e8b --- /dev/null +++ b/madlibs/saved stories/generatedStory-27-02-2020-21:32:20.txt @@ -0,0 +1,5 @@ +AMC Cinemas Pre-Show Policy + +Thank you for choosing AMC Cinemas. Where we make movie moments AMC l. Your safety is l to us, so remember, keep a asdf on your valuables. Be sure to report any asdf behavior. And please take a moment to find any emergency exits near you. Make sure to stock up on asdfdfdsasd and sdf at the concessions bar. Enjoy your movie, asdf and we thank you for choosing AMC Cinemas as your destination to watch that movie. Please, silence your asdf now and be quiet and courteous of your peers. And now, ladies and gentlemen, here are some special previews coming to an AMC near you. + +Generated by Caleb Fontenot's madlibs.py \ No newline at end of file