diff --git a/tortoise_utils.py b/tortoise_utils.py index 109087e..c97b80c 100644 --- a/tortoise_utils.py +++ b/tortoise_utils.py @@ -38,7 +38,7 @@ def process_textfile(file_path: str) -> list[str]: text = clean_text(text) return text -def tts(paper_name: str): +def tts(file_path: str): # load tts model # ADD PATH tts = TextToSpeech( @@ -50,7 +50,7 @@ def tts(paper_name: str): ) # process text file - texts = process_textfile(f"./llm/scripts/{paper_name}.txt") + texts = process_textfile(file_path) # generate audio for each chunk of text all_audio_chunks = [] @@ -65,6 +65,9 @@ def tts(paper_name: str): all_audio_chunks.append(gen) + book_name_ext = os.path.basename(file_path) + paper_name = os.path.splitext(book_name_ext)[0] + # concatenate all audio chunks full_audio = torch.cat(all_audio_chunks, dim=-1) torchaudio.save(f"./audio/raw/{paper_name}.wav", full_audio, 24000)