Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,13 @@ speaker_model = EncoderClassifier.from_hparams(
|
|
19 |
savedir=os.path.join("/tmp", "speechbrain/spkrec-xvect-voxceleb")
|
20 |
)
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Load a sample from the dataset for speaker embedding
|
23 |
try:
|
24 |
dataset = load_dataset("Yassmen/TTS_English_Technical_data", split="train", trust_remote_code=True)
|
@@ -30,12 +37,6 @@ except Exception as e:
|
|
30 |
# Use a random speaker embedding as fallback
|
31 |
speaker_embedding = torch.randn(1, 512)
|
32 |
|
33 |
-
def create_speaker_embedding(waveform):
|
34 |
-
with torch.no_grad():
|
35 |
-
speaker_embeddings = speaker_model.encode_batch(torch.tensor(waveform))
|
36 |
-
speaker_embeddings = torch.nn.functional.normalize(speaker_embeddings, dim=2)
|
37 |
-
speaker_embeddings = speaker_embeddings.squeeze().cpu().numpy()
|
38 |
-
return speaker_embeddings
|
39 |
|
40 |
def text_to_speech(text):
|
41 |
# Clean up text
|
|
|
19 |
savedir=os.path.join("/tmp", "speechbrain/spkrec-xvect-voxceleb")
|
20 |
)
|
21 |
|
22 |
+
def create_speaker_embedding(waveform):
|
23 |
+
with torch.no_grad():
|
24 |
+
speaker_embeddings = speaker_model.encode_batch(torch.tensor(waveform))
|
25 |
+
speaker_embeddings = torch.nn.functional.normalize(speaker_embeddings, dim=2)
|
26 |
+
speaker_embeddings = speaker_embeddings.squeeze().cpu().numpy()
|
27 |
+
return speaker_embeddings
|
28 |
+
|
29 |
# Load a sample from the dataset for speaker embedding
|
30 |
try:
|
31 |
dataset = load_dataset("Yassmen/TTS_English_Technical_data", split="train", trust_remote_code=True)
|
|
|
37 |
# Use a random speaker embedding as fallback
|
38 |
speaker_embedding = torch.randn(1, 512)
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
def text_to_speech(text):
|
42 |
# Clean up text
|