mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-11-20 13:07:52 +09:00
Merge pull request #37 from rakuri255/fix_karaoke_video_txt_name
- Fix karaoke video naming
This commit is contained in:
3 files changed
+27
-15
No files matched your search
+14
-4
@@ -23,6 +23,7 @@ from moduls.Log import PRINT_ULTRASTAR, print_red_highlighted_text, print_blue_h
|
||||
print_gold_highlighted_text, \
|
||||
print_light_blue_highlighted_text
|
||||
from matplotlib import pyplot as plt
|
||||
from moduls.Ultrastar.ultrastar_txt import UltrastarTxt
|
||||
from Settings import Settings
|
||||
from tqdm import tqdm
|
||||
from moduls.DeviceDetection.device_detection import get_available_device
|
||||
@@ -272,7 +273,7 @@ def run():
|
||||
# Write Ultrastar txt
|
||||
if isAudio:
|
||||
real_bpm, ultrastar_file_output = create_ultrastar_txt_from_automation(audio_separation_path,
|
||||
basename_without_ext, real_bpm,
|
||||
basename_without_ext,
|
||||
song_output, transcribed_data,
|
||||
ultrastar_audio_input_path,
|
||||
ultrastar_note_numbers, language)
|
||||
@@ -334,24 +335,33 @@ def create_ultrastar_txt_from_ultrastar_data(song_output, ultrastar_class, ultra
|
||||
return output_repitched_ultrastar
|
||||
|
||||
|
||||
def create_ultrastar_txt_from_automation(audio_separation_path, basename_without_ext, real_bpm, song_output,
|
||||
def create_ultrastar_txt_from_automation(audio_separation_path, basename_without_ext, song_output,
|
||||
transcribed_data, ultrastar_audio_input_path, ultrastar_note_numbers,
|
||||
language):
|
||||
ultrastar_header = UltrastarTxt()
|
||||
ultrastar_header.title = basename_without_ext
|
||||
ultrastar_header.artist = basename_without_ext
|
||||
ultrastar_header.mp3 = basename_without_ext + ".mp3"
|
||||
ultrastar_header.video = basename_without_ext + ".mp4"
|
||||
ultrastar_header.language = language
|
||||
|
||||
real_bpm = get_bpm_from_file(ultrastar_audio_input_path)
|
||||
ultrastar_file_output = os.path.join(song_output, basename_without_ext + '.txt')
|
||||
ultrastar_writer.create_ultrastar_txt_from_automation(transcribed_data, ultrastar_note_numbers,
|
||||
ultrastar_file_output,
|
||||
basename_without_ext, language, real_bpm)
|
||||
ultrastar_header, real_bpm)
|
||||
if settings.create_karaoke:
|
||||
no_vocals_path = os.path.join(audio_separation_path, "no_vocals.wav")
|
||||
title = basename_without_ext + " [Karaoke]"
|
||||
ultrastar_header.title = title
|
||||
ultrastar_header.mp3 = title + ".mp3"
|
||||
karaoke_output_path = os.path.join(song_output, title)
|
||||
karaoke_audio_output_path = karaoke_output_path + ".mp3"
|
||||
convert_wav_to_mp3(no_vocals_path, karaoke_audio_output_path)
|
||||
karaoke_txt_output_path = karaoke_output_path + ".txt"
|
||||
ultrastar_writer.create_ultrastar_txt_from_automation(transcribed_data, ultrastar_note_numbers,
|
||||
karaoke_txt_output_path,
|
||||
title, language, real_bpm)
|
||||
ultrastar_header, real_bpm)
|
||||
return real_bpm, ultrastar_file_output
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ class UltrastarTxt:
|
||||
mp3 = ''
|
||||
gap = ''
|
||||
bpm = ''
|
||||
creator = 'UltraSinger [GitHub]'
|
||||
fixer = 'YOUR NAME'
|
||||
startBeat = []
|
||||
startTimes = []
|
||||
endTimes = []
|
||||
|
||||
@@ -20,7 +20,7 @@ def get_language_name(language):
|
||||
return langcodes.Language.make(language=language).display_name()
|
||||
|
||||
|
||||
def create_ultrastar_txt_from_automation(transcribed_data, note_numbers, ultrastar_file_output, title, language,
|
||||
def create_ultrastar_txt_from_automation(transcribed_data, note_numbers, ultrastar_file_output, ultrastar_class,
|
||||
bpm=120):
|
||||
print("{} Creating {} from transcription.".format(PRINT_ULTRASTAR, ultrastar_file_output))
|
||||
|
||||
@@ -31,16 +31,16 @@ def create_ultrastar_txt_from_automation(transcribed_data, note_numbers, ultrast
|
||||
with open(ultrastar_file_output, 'w', encoding='utf8') as f:
|
||||
gap = transcribed_data[0].start
|
||||
|
||||
f.write('#ARTIST:' + title + '\n')
|
||||
f.write('#TITLE:' + title + '\n')
|
||||
f.write('#CREATOR:UltraSinger [GitHub]' + '\n')
|
||||
f.write('#FIXER:YOUR NAME' + '\n')
|
||||
if language is not None:
|
||||
f.write('#LANGUAGE:' + get_language_name(language) + '\n')
|
||||
f.write('#MP3:' + title + '.mp3\n')
|
||||
f.write('#VIDEO:' + title + '.mp4\n')
|
||||
f.write('#BPM:' + str(round(ultrastar_bpm, 2)) + '\n') # not the real BPM!
|
||||
f.write('#GAP:' + str(int(gap * 1000)) + '\n')
|
||||
f.write(f'#ARTIST:{ultrastar_class.artist}\n')
|
||||
f.write(f'#TITLE:{ultrastar_class.title}\n')
|
||||
f.write(f'#CREATOR:{ultrastar_class.creator}\n')
|
||||
f.write(f'#FIXER:{ultrastar_class.fixer}\n')
|
||||
if ultrastar_class.language is not None:
|
||||
f.write(f'#LANGUAGE:' + get_language_name(ultrastar_class.language) + '\n')
|
||||
f.write(f'#MP3:{ultrastar_class.mp3}\n')
|
||||
f.write(f'#VIDEO:{ultrastar_class.video}\n')
|
||||
f.write(f'#BPM:' + str(round(ultrastar_bpm, 2)) + '\n') # not the real BPM!
|
||||
f.write(f'#GAP:' + str(int(gap * 1000)) + '\n')
|
||||
|
||||
# Write the singing part
|
||||
previous_end_beat = 0
|
||||
|
||||
Reference in new issue
Block a user