reab5555 commited on
Commit
9263021
·
verified ·
1 Parent(s): b9da44c

Update voice_analysis.py

Browse files
Files changed (1) hide show
  1. voice_analysis.py +5 -0
voice_analysis.py CHANGED
@@ -33,6 +33,7 @@ def get_speaker_embeddings(audio_path, diarization, model_name="pyannote/embeddi
33
  model.eval() # Set the model to evaluation mode
34
 
35
  waveform, sample_rate = torchaudio.load(audio_path)
 
36
  embeddings = []
37
 
38
  for turn, _, speaker in diarization.itertracks(yield_label=True):
@@ -40,6 +41,8 @@ def get_speaker_embeddings(audio_path, diarization, model_name="pyannote/embeddi
40
  end_frame = int(turn.end * sample_rate)
41
 
42
  segment = waveform[:, start_frame:end_frame]
 
 
43
  if segment.shape[1] == 0:
44
  continue
45
 
@@ -54,6 +57,8 @@ def get_speaker_embeddings(audio_path, diarization, model_name="pyannote/embeddi
54
 
55
  # Reshape the segment to match the model's expected input
56
  segment = segment.unsqueeze(0) # Add batch dimension
 
 
57
 
58
  with torch.no_grad():
59
  embedding = model(segment) # Pass the tensor directly, not a dictionary
 
33
  model.eval() # Set the model to evaluation mode
34
 
35
  waveform, sample_rate = torchaudio.load(audio_path)
36
+ print(f"Sample rate: {sample_rate}")
37
  embeddings = []
38
 
39
  for turn, _, speaker in diarization.itertracks(yield_label=True):
 
41
  end_frame = int(turn.end * sample_rate)
42
 
43
  segment = waveform[:, start_frame:end_frame]
44
+ print(f"Segment shape before processing: {segment.shape}")
45
+
46
  if segment.shape[1] == 0:
47
  continue
48
 
 
57
 
58
  # Reshape the segment to match the model's expected input
59
  segment = segment.unsqueeze(0) # Add batch dimension
60
+
61
+ print(f"Segment shape after processing: {segment.shape}")
62
 
63
  with torch.no_grad():
64
  embedding = model(segment) # Pass the tensor directly, not a dictionary