diff --git a/script.py b/script.py index a227f3d..9860e81 100644 --- a/script.py +++ b/script.py @@ -551,15 +551,10 @@ 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_file_str = output_file.as_posix() + output_filename = get_output_filename(state) generate_response = send_generate_request( - cleaned_part, voice_to_use, language_code, output_file_str + cleaned_part, voice_to_use, language_code, output_filename ) audio_path = generate_response.get("data", {}).get("audio_path") audio_files_paragraph.append(audio_path) @@ -580,14 +575,9 @@ 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. - 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) + output_filename = get_output_filename(state) generate_response = send_generate_request( - cleaned_part, params["voice"], language_code, output_file_str + cleaned_part, params["voice"], language_code, output_filename ) audio_path = generate_response.get("data", {}).get("audio_path") final_output_file = audio_path @@ -627,9 +617,11 @@ def output_modifier(string, state): def get_output_filename(state): - return Path( - f'{params["output_folder_wav"]}/{state["character_menu"]}_{str(uuid.uuid4())[:8]}.wav' - ).as_posix() + # 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() ###############################################