rap_lyrics_english / songs /lyricstotxt.py
Cropinky's picture
adding required files
36ec053
raw
history blame contribute delete
714 Bytes
import os
from pathlib import Path
import sys
foldername = sys.argv[1]
"""
this script gives the text <bos> and <eos> tokens it could have all been one script but yeah
the foldername is passed and an argument when calling the script
"""
header = ['text']
songsfile = open(foldername+'.txt', 'w', encoding='UTF8')
for _,_, files in os.walk(foldername):
for filename in files:
print(filename)
textsfile = open(Path(foldername, filename))
texts = textsfile.read()
texts = texts.split('*'*50)
texts = texts[1:]
for text in texts:
text_with_tokens = f"<BOS>{text}<EOS>\n"
#print(text_with_tokens)
songsfile.write(text_with_tokens)