Saurabh Kumar commited on
Commit
c285d1d
1 Parent(s): bbb27fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -20,16 +20,16 @@ speaker_model = EncoderClassifier.from_hparams(
20
  savedir=os.path.join("/tmp", "speechbrain/spkrec-xvect-voxceleb")
21
  )
22
 
23
- # # Load a sample from the dataset for speaker embedding
24
- # try:
25
- # dataset = load_dataset("mozilla-foundation/common_voice_17_0", "hi", split="validated", trust_remote_code=True)
26
- # dataset = dataset.cast_column("audio", Audio(sampling_rate=16000))
27
- # sample = dataset[0]
28
- # speaker_embedding = create_speaker_embedding(sample['audio']['array'])
29
- # except Exception as e:
30
- # print(f"Error loading dataset: {e}")
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():
 
20
  savedir=os.path.join("/tmp", "speechbrain/spkrec-xvect-voxceleb")
21
  )
22
 
23
+ # Load a sample from the dataset for speaker embedding
24
+ try:
25
+ dataset = load_dataset("mozilla-foundation/common_voice_17_0", "hi", split="validated", trust_remote_code=True)
26
+ dataset = dataset.cast_column("audio", Audio(sampling_rate=16000))
27
+ sample = dataset[0]
28
+ speaker_embedding = create_speaker_embedding(sample['audio']['array'])
29
+ except Exception as e:
30
+ print(f"Error loading dataset: {e}")
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():