daily pastebin goal
25%
SHARE
TWEET

Untitled

lukethenerd Feb 17th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. print(os.getcwd())
  3. import pyttsx3
  4. import subprocess32
  5. import threading
  6. import mpg123
  7. import ffmpeg
  8. from time import sleep
  9. from asyncio import
  10.  
  11. # VARIABLES
  12. beat_to_play = "beat.mp3"
  13.  
  14. slowdown_rate = 35  # higher value means slower speech... keep it between ~50 and 0 depending on how fast the beat is.
  15. intro = 24  # amount in seconds it takes from the start of the beat to when the rapping should begin... how many seconds the AI waits to start rapping.
  16.  
  17. #code time baybeeeeeee
  18. def play_mp3(path):
  19.     subprocess32.Popen(['mpg123', '-q', path]).wait()
  20.  
  21. engine = pyttsx3.init()
  22.  
  23. def letters(input):
  24.     valids = []
  25.     for character in input:
  26.         if character.isalpha() or character == "," or character == "'" or character == " ":
  27.             valids.append(character)
  28.     return ''.join(valids)
  29.  
  30. lyrics = open('bino_rap1.txt').read().split("\n")  # this reads lines from a file called 'neural_rap.txt'
  31. # print lyrics
  32. rate = engine.getProperty('rate')
  33. engine.setProperty('rate', 'rate - slowdown_rate')
  34. voices = engine.getProperty('voices')
  35.  
  36. wholesong = ""
  37. for i in lyrics:
  38.     wholesong += i + " ... "
  39.  
  40.  
  41. def sing():
  42.     for line in wholesong.split(" ... "):
  43.         if line == "..." or line == "":
  44.             for i in range(18):
  45.                 engine.say("    ")
  46.         else:
  47.             engine.say(str(line))
  48.     engine.runAndWait()
  49.  
  50.  
  51. def beat():
  52.     play_mp3(beat_to_play)
  53.  
  54. Thread(target=beat).start()
  55. sleep(intro)  # just waits a little bit to start talking
  56. Thread(target=sing).start()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top