lukethenerd Feb 17th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import os
- import pyttsx3
- import subprocess32
- import threading
- import mpg123
- import ffmpeg
- from time import sleep
- from asyncio import
- # VARIABLES
- beat_to_play = "beat.mp3"
- slowdown_rate = 35 # higher value means slower speech... keep it between ~50 and 0 depending on how fast the beat is.
- 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.
- #code time baybeeeeeee
- def play_mp3(path):
- subprocess32.Popen(['mpg123', '-q', path]).wait()
- engine = pyttsx3.init()
- def letters(input):
- valids = 
- for character in input:
- if character.isalpha() or character == "," or character == "'" or character == " ":
- return ''.join(valids)
- lyrics = open('bino_rap1.txt').read().split("\n") # this reads lines from a file called 'neural_rap.txt'
- # print lyrics
- rate = engine.getProperty('rate')
- engine.setProperty('rate', 'rate - slowdown_rate')
- voices = engine.getProperty('voices')
- wholesong = ""
- for i in lyrics:
- wholesong += i + " ... "
- def sing():
- for line in wholesong.split(" ... "):
- if line == "..." or line == "":
- for i in range(18):
- engine.say(" ")
- def beat():
- sleep(intro) # just waits a little bit to start talking
RAW Paste Data