Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ try:
|
|
| 24 |
"pyannote/speaker-diarization-3.1",
|
| 25 |
use_auth_token=os.environ["HF_TOKEN"]
|
| 26 |
)
|
| 27 |
-
device = torch.device("cuda
|
| 28 |
diarization_pipeline.to(device)
|
| 29 |
except Exception as e:
|
| 30 |
print(f"Error initializing diarization pipeline: {e}")
|
|
@@ -36,7 +36,7 @@ MODEL_NAME = "openai/whisper-medium"
|
|
| 36 |
FILE_LIMIT_MB = 1000
|
| 37 |
YT_LENGTH_LIMIT_S = 3600
|
| 38 |
|
| 39 |
-
device =
|
| 40 |
|
| 41 |
pipe = pipeline(
|
| 42 |
task="automatic-speech-recognition",
|
|
@@ -49,6 +49,7 @@ pipe = pipeline(
|
|
| 49 |
|
| 50 |
|
| 51 |
|
|
|
|
| 52 |
def associate_speakers_with_timestamps(transcription_result, diarization, tolerance=0.1, min_segment_duration=0.5):
|
| 53 |
word_segments = transcription_result['chunks']
|
| 54 |
diarization_segments = list(diarization.itertracks(yield_label=True))
|
|
|
|
| 24 |
"pyannote/speaker-diarization-3.1",
|
| 25 |
use_auth_token=os.environ["HF_TOKEN"]
|
| 26 |
)
|
| 27 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 28 |
diarization_pipeline.to(device)
|
| 29 |
except Exception as e:
|
| 30 |
print(f"Error initializing diarization pipeline: {e}")
|
|
|
|
| 36 |
FILE_LIMIT_MB = 1000
|
| 37 |
YT_LENGTH_LIMIT_S = 3600
|
| 38 |
|
| 39 |
+
device = 0 if torch.cuda.is_available() else "cpu"
|
| 40 |
|
| 41 |
pipe = pipeline(
|
| 42 |
task="automatic-speech-recognition",
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
+
|
| 53 |
def associate_speakers_with_timestamps(transcription_result, diarization, tolerance=0.1, min_segment_duration=0.5):
|
| 54 |
word_segments = transcription_result['chunks']
|
| 55 |
diarization_segments = list(diarization.itertracks(yield_label=True))
|