Skip to content

Commit

Permalink
[cli] support resampling (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdliang11 authored Nov 13, 2023
1 parent 06dc50f commit 3a29224
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wespeaker/cli/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ def extract_embedding(self, audio_path: str):
else: # all silence, nospeech
return None
pcm = pcm.to(torch.float)
if sample_rate != self.resample_rate:
pcm = torchaudio.transforms.Resample(
orig_freq=sample_rate, new_freq=self.resample_rate)(pcm)
feats = kaldi.fbank(pcm,
num_mel_bins=80,
frame_length=25,
frame_shift=10,
energy_floor=0.0,
sample_frequency=16000)
sample_frequency=self.resample_rate)
feats = feats - torch.mean(feats, 0) # CMN
feats = feats.unsqueeze(0)
feats = feats.to(self.device)
Expand Down

0 comments on commit 3a29224

Please sign in to comment.