Update voice_analysis.py
Browse files- voice_analysis.py +8 -1
voice_analysis.py
CHANGED
@@ -22,7 +22,14 @@ def diarize_speakers(audio_path):
|
|
22 |
diarization = pipeline(audio_path)
|
23 |
return diarization
|
24 |
|
25 |
-
def get_speaker_embeddings(audio_path, diarization,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
waveform, sample_rate = torchaudio.load(audio_path)
|
27 |
embeddings = []
|
28 |
|
|
|
22 |
diarization = pipeline(audio_path)
|
23 |
return diarization
|
24 |
|
25 |
+
def get_speaker_embeddings(audio_path, diarization, model_name="pyannote/embedding"):
|
26 |
+
hf_token = os.environ.get("py_annote_hf_token")
|
27 |
+
|
28 |
+
if not hf_token:
|
29 |
+
raise ValueError("py_annote_hf_token environment variable is not set. Please check your Hugging Face Space's Variables and secrets section.")
|
30 |
+
|
31 |
+
model = Model.from_pretrained(model_name, use_auth_token=hf_token)
|
32 |
+
|
33 |
waveform, sample_rate = torchaudio.load(audio_path)
|
34 |
embeddings = []
|
35 |
|