Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Spleeter support #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
**Check out [my blog](https://medium.com/@chriswang030) on my progress and process throughout GSoC 2019!**

## about
**This branch provides [Spleeter](https://github.com/deezer/spleeter) support, to try it out provide --spleeter to the playback.py script**
*Note: Spleeter is installed with setup.sh (needs conda)*

Given an audio file of some recognizable song, autosynch will try to align its
lyrics to their temporal location in the song. The song lyrics must be available
on [Genius](https://genius.com).
Expand Down
13 changes: 11 additions & 2 deletions autosynch/playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from autosynch.align import line_align

def playback(audio_file, align_file, artist=None, song=None, save=None,
chunk_size=1024, verbose=False):
chunk_size=1024, verbose=False, spleeter=False):
"""
Plays audio with lyrics displayed at designated timestamp. If align_file is
None, then full alignment process is performed with song and artist data.
Expand Down Expand Up @@ -41,7 +41,14 @@ def playback(audio_file, align_file, artist=None, song=None, save=None,

print('Processing...\n')
print(audio_file)
align = line_align({'song': song, 'artist': artist, 'path': audio_file}, save)[0]['align']

if spleeter:
print("Trying Spleeter instead...\n")
subprocess.call(["spleeter", "separate", "-i", audio_file, "-p", "spleeter:2stems", "-o", "spleeter_output"])
subprocess.call(["mv", "spleeter_output/" + os.path.splitext(os.path.split(audio_file)[1])[0] + "/vocals.wav", os.path.splitext(audio_file)[0] + '_voice.wav'])
subprocess.call(["rm", "-rf", "spleeter_output"])

align = line_align({'song': song, 'artist': artist, 'path': audio_file}, save, do_twinnet=not spleeter)[0]['align']
else:
with open(align_file, 'r') as f:
align = yaml.safe_load(f)['align']
Expand Down Expand Up @@ -114,6 +121,8 @@ def main():
help='path to previously saved align file')
parser.add_argument('-s', '--save', nargs='?', const=os.getcwd(),
metavar='SAVE_DIR', help='directory for saving align file')
parser.add_argument('-spl', '--spleeter',
help='try out spleeter instead of mad twinnet', action='store_true')

args = vars(parser.parse_args())

Expand Down
3 changes: 3 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
sudo apt-get update
sudo apt-get install portaudio19-dev
sudo apt-get install sox
sudo apt-get install libsox-fmt-mp3
git clone https://github.com/Deezer/spleeter
conda install -c conda-forge spleeter
fi