add a loop over all speakers
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
.venv
|
||||
output.wav
|
||||
output_wav
|
||||
@@ -0,0 +1,61 @@
|
||||
import torch
|
||||
import time
|
||||
from TTS.api import TTS
|
||||
|
||||
# Get device
|
||||
if torch.cuda.is_available():
|
||||
device = "cuda"
|
||||
else:
|
||||
print('Running on cpu')
|
||||
device= "cpu"
|
||||
|
||||
# List available 🐸TTS models
|
||||
print(TTS().list_models())
|
||||
|
||||
# Initialize TTS
|
||||
start_init = time.time()
|
||||
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
||||
end_init = time.time()
|
||||
print(f"Initialization time: {end_init - start_init:.2f} seconds")
|
||||
|
||||
# List speakers
|
||||
print(tts.speakers)
|
||||
|
||||
# Run TTS
|
||||
# ❗ XTTS supports both, but many models allow only one of the `speaker` and
|
||||
# `speaker_wav` arguments
|
||||
|
||||
# TTS with list of amplitude values as output, clone the voice from `speaker_wav`
|
||||
# wav = tts.tts(
|
||||
# text="Hello world!",
|
||||
# speaker_wav="en_sample.wav",
|
||||
# language="en"
|
||||
# )
|
||||
|
||||
# Create output directory
|
||||
import os
|
||||
os.makedirs("output_wav", exist_ok=True)
|
||||
|
||||
# Generate sample for each speaker
|
||||
start_gen = time.time()
|
||||
total_speakers = len(tts.speakers)
|
||||
print(f"Starting generation for {total_speakers} speakers...")
|
||||
|
||||
for idx, speaker in enumerate(tts.speakers, 1):
|
||||
# Sanitize speaker name for filename
|
||||
safe_name = speaker.replace(" ", "_").replace("/", "-")
|
||||
filename = f"output_wav/{safe_name}.wav"
|
||||
|
||||
# Generate audio
|
||||
tts.tts_to_file(
|
||||
text="Bitte beachten Sie: Sicherheitscheck 5 ist jetzt geöffnet. Bitte warten Sie im bereitgestellten Wartebereich, bis Sie aufgerufen werden.",
|
||||
speaker=speaker,
|
||||
language="de",
|
||||
file_path=filename
|
||||
)
|
||||
|
||||
# Print progress
|
||||
progress = f"[{idx}/{total_speakers}] {filename}"
|
||||
print(progress)
|
||||
end_gen = time.time()
|
||||
print(f"Generation time: {end_gen - start_gen:.2f} seconds")
|
||||
BIN
Binary file not shown.
Generated
+5354
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,17 @@
|
||||
[project]
|
||||
name = "xtts-test"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = [
|
||||
{name = "pstruebi",email = "struebin.patrick@gmail.com"}
|
||||
]
|
||||
#readme = "README.md"
|
||||
requires-python = ">=3.9.0, <3.12"
|
||||
dependencies = [
|
||||
"coqui-tts"
|
||||
]
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user