Solo448 commited on
Commit
e500175
1 Parent(s): 43606fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -19,13 +19,7 @@ speaker_model = EncoderClassifier.from_hparams(
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("Sajjo/bangala_data_v3", split="train", trust_remote_code=True)
@@ -37,6 +31,13 @@ except Exception as e:
37
  # Use a random speaker embedding as fallback
38
  speaker_embedding = torch.randn(1, 512)
39
 
 
 
 
 
 
 
 
40
  def text_to_speech(text):
41
  # Clean up text
42
  replacements = [
 
19
  savedir=os.path.join("/tmp", "speechbrain/spkrec-xvect-voxceleb")
20
  )
21
 
22
+
 
 
 
 
 
 
23
  # Load a sample from the dataset for speaker embedding
24
  try:
25
  dataset = load_dataset("Sajjo/bangala_data_v3", split="train", trust_remote_code=True)
 
31
  # Use a random speaker embedding as fallback
32
  speaker_embedding = torch.randn(1, 512)
33
 
34
+ def create_speaker_embedding(waveform):
35
+ with torch.no_grad():
36
+ speaker_embeddings = speaker_model.encode_batch(torch.tensor(waveform))
37
+ speaker_embeddings = torch.nn.functional.normalize(speaker_embeddings, dim=2)
38
+ speaker_embeddings = speaker_embeddings.squeeze().cpu().numpy()
39
+ return speaker_embeddings
40
+
41
  def text_to_speech(text):
42
  # Clean up text
43
  replacements = [