diff --git a/script.py b/script.py index 19bdb2b..a641bf9 100644 --- a/script.py +++ b/script.py @@ -551,10 +551,15 @@ def output_modifier(string, state): else: cleaned_part = html.unescape(part.replace('< ', '').replace('< ', '').replace('< ', '')) voice_to_use = params["narrator_voice"] + # Check if character name exists and if not, just call it TTSOUT_ + if "character_menu" in state: + output_file = Path(f'{params["output_folder_wav"]}/{state["character_menu"]}_{int(time.time())}_{i}.wav') + else: + output_file = Path(f'{params["output_folder_wav"]}/TTSOUT_{int(time.time())}_{i}.wav') # Generate that TTS and output to a file - output_filename = get_output_filename(state) + output_file_str = output_file.as_posix() generate_response = send_generate_request( - cleaned_part, voice_to_use, language_code, output_filename + cleaned_part, voice_to_use, language_code, output_file_str ) audio_path = generate_response.get("data", {}).get("audio_path") audio_files_paragraph.append(audio_path) @@ -575,9 +580,14 @@ def output_modifier(string, state): ) cleaned_part = html.unescape(processed_string) # Process the part and give it a non-character name if being used vai API or standalone. - output_filename = get_output_filename(state) + if "character_menu" in state: + output_file = Path(f'{params["output_folder_wav"]}/{state["character_menu"]}_{int(time.time())}.wav') + else: + output_file = Path(f'{params["output_folder_wav"]}/TTSOUT_{int(time.time())}.wav') + output_file_str = output_file.as_posix() + output_file = get_output_filename(state) generate_response = send_generate_request( - cleaned_part, params["voice"], language_code, output_filename + cleaned_part, params["voice"], language_code, output_file_str ) audio_path = generate_response.get("data", {}).get("audio_path") final_output_file = audio_path @@ -617,11 +627,9 @@ def output_modifier(string, state): def get_output_filename(state): - # Check if character name exists and if not, just call it TTSOUT_ - if "character_menu" in state: - return Path(f'{params["output_folder_wav"]}/{state["character_menu"]}_{int(time.time())}.wav').as_posix() - else: - return Path(f'{params["output_folder_wav"]}/TTSOUT_{int(time.time())}.wav').as_posix() + return Path( + f'{params["output_folder_wav"]}/{state["character_menu"]}_{str(uuid.uuid4())[:8]}.wav' + ).as_posix() ###############################################