forked from mrq/ai-voice-cloning
updating utils
This commit is contained in:
parent
02e3a46700
commit
a1d0ea3232
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user