Spaces:
Build error
Build error
Update utils_hf.py
Browse files- utils_hf.py +3 -1
utils_hf.py
CHANGED
|
@@ -3,6 +3,7 @@ import streamlit as st
|
|
| 3 |
import yt_dlp
|
| 4 |
import numpy as np
|
| 5 |
import soundfile as sf
|
|
|
|
| 6 |
from moviepy.editor import AudioFileClip
|
| 7 |
from transformers import pipeline
|
| 8 |
from pyannote.audio.pipelines.utils.hook import ProgressHook
|
|
@@ -13,6 +14,7 @@ whisper_pipeline = pipeline(
|
|
| 13 |
generate_kwargs={"language": "<|es|>", "task": "transcribe"}
|
| 14 |
)
|
| 15 |
|
|
|
|
| 16 |
def diarize_short_segment(audio_path, token, start_time=0, end_time=600):
|
| 17 |
"""
|
| 18 |
Realiza la diarizaci贸n solo en un segmento corto del archivo de audio.
|
|
@@ -44,7 +46,7 @@ def diarize_short_segment(audio_path, token, start_time=0, end_time=600):
|
|
| 44 |
diarization_text += f"{segment.start:.2f} - {segment.end:.2f}: {speaker}\n"
|
| 45 |
speakers.add(speaker)
|
| 46 |
|
| 47 |
-
return diarization_text,
|
| 48 |
except Exception as e:
|
| 49 |
st.error(f"Error al realizar la diarizaci贸n: {e}")
|
| 50 |
return None, 0
|
|
|
|
| 3 |
import yt_dlp
|
| 4 |
import numpy as np
|
| 5 |
import soundfile as sf
|
| 6 |
+
import pyannote.audio
|
| 7 |
from moviepy.editor import AudioFileClip
|
| 8 |
from transformers import pipeline
|
| 9 |
from pyannote.audio.pipelines.utils.hook import ProgressHook
|
|
|
|
| 14 |
generate_kwargs={"language": "<|es|>", "task": "transcribe"}
|
| 15 |
)
|
| 16 |
|
| 17 |
+
|
| 18 |
def diarize_short_segment(audio_path, token, start_time=0, end_time=600):
|
| 19 |
"""
|
| 20 |
Realiza la diarizaci贸n solo en un segmento corto del archivo de audio.
|
|
|
|
| 46 |
diarization_text += f"{segment.start:.2f} - {segment.end:.2f}: {speaker}\n"
|
| 47 |
speakers.add(speaker)
|
| 48 |
|
| 49 |
+
return diarization_segments, diarization_text, speakers
|
| 50 |
except Exception as e:
|
| 51 |
st.error(f"Error al realizar la diarizaci贸n: {e}")
|
| 52 |
return None, 0
|