Spaces:
Runtime error
Runtime error
Update voice_analysis.py
Browse files- voice_analysis.py +3 -3
voice_analysis.py
CHANGED
|
@@ -2,9 +2,9 @@ import moviepy.editor as mp
|
|
| 2 |
from pyannote.audio import Pipeline
|
| 3 |
import torch
|
| 4 |
import torchaudio
|
|
|
|
| 5 |
from pyannote.core import Segment
|
| 6 |
from pyannote.audio import Model
|
| 7 |
-
from pyannote.audio.pipelines.utils.hook import IteratorHook
|
| 8 |
import os
|
| 9 |
|
| 10 |
def extract_audio_from_video(video_path):
|
|
@@ -14,11 +14,10 @@ def extract_audio_from_video(video_path):
|
|
| 14 |
return audio_path
|
| 15 |
|
| 16 |
def diarize_speakers(audio_path):
|
| 17 |
-
# Load the token from the environment variable
|
| 18 |
hf_token = os.environ.get("py_annote_hf_token")
|
| 19 |
|
| 20 |
if not hf_token:
|
| 21 |
-
raise ValueError("
|
| 22 |
|
| 23 |
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1", use_auth_token=hf_token)
|
| 24 |
diarization = pipeline(audio_path)
|
|
@@ -51,6 +50,7 @@ def get_speaker_embeddings(audio_path, diarization, model_name="pyannote/embeddi
|
|
| 51 |
return embeddings
|
| 52 |
|
| 53 |
def align_voice_embeddings(voice_embeddings, frame_count, fps):
|
|
|
|
| 54 |
aligned_embeddings = []
|
| 55 |
current_embedding_index = 0
|
| 56 |
|
|
|
|
| 2 |
from pyannote.audio import Pipeline
|
| 3 |
import torch
|
| 4 |
import torchaudio
|
| 5 |
+
from pyannote.audio import Pipeline
|
| 6 |
from pyannote.core import Segment
|
| 7 |
from pyannote.audio import Model
|
|
|
|
| 8 |
import os
|
| 9 |
|
| 10 |
def extract_audio_from_video(video_path):
|
|
|
|
| 14 |
return audio_path
|
| 15 |
|
| 16 |
def diarize_speakers(audio_path):
|
|
|
|
| 17 |
hf_token = os.environ.get("py_annote_hf_token")
|
| 18 |
|
| 19 |
if not hf_token:
|
| 20 |
+
raise ValueError("py_annote_hf_token environment variable is not set. Please check your Hugging Face Space's Variables and secrets section.")
|
| 21 |
|
| 22 |
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1", use_auth_token=hf_token)
|
| 23 |
diarization = pipeline(audio_path)
|
|
|
|
| 50 |
return embeddings
|
| 51 |
|
| 52 |
def align_voice_embeddings(voice_embeddings, frame_count, fps):
|
| 53 |
+
import numpy as np
|
| 54 |
aligned_embeddings = []
|
| 55 |
current_embedding_index = 0
|
| 56 |
|