Spaces:
Build error
Build error
jerry f
commited on
Commit
·
e0bc8d0
1
Parent(s):
3509591
use cuda or cpu
Browse files- Dockerfile +3 -0
- src/CallCenter.py +5 -1
- src/transcribe_files.py +9 -1
- src/transcript_analysis.py +2 -2
Dockerfile
CHANGED
|
@@ -13,6 +13,9 @@ COPY requirements.txt ./
|
|
| 13 |
COPY src/ ./src/
|
| 14 |
|
| 15 |
RUN pip3 install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
EXPOSE 8501
|
| 18 |
|
|
|
|
| 13 |
COPY src/ ./src/
|
| 14 |
|
| 15 |
RUN pip3 install -r requirements.txt
|
| 16 |
+
RUN pip3 install torch==2.7.0 --index-url https://download.pytorch.org/whl/cu126
|
| 17 |
+
RUN pip3 install torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu126
|
| 18 |
+
RUN pip3 install torchvision==0.22.0 --index-url https://download.pytorch.org/whl/cu126
|
| 19 |
|
| 20 |
EXPOSE 8501
|
| 21 |
|
src/CallCenter.py
CHANGED
|
@@ -22,7 +22,11 @@ pipelineDiary = Pipeline.from_pretrained(
|
|
| 22 |
"pyannote/speaker-diarization-3.1",
|
| 23 |
use_auth_token=hugging_face)
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
def diarize_wav_file(file_name):
|
| 28 |
print("DIARIZING " + file_name)
|
|
|
|
| 22 |
"pyannote/speaker-diarization-3.1",
|
| 23 |
use_auth_token=hugging_face)
|
| 24 |
|
| 25 |
+
if torch.cuda.is_available():
|
| 26 |
+
print("diarize_wav_file Using CUDA")
|
| 27 |
+
pipelineDiary.to(torch.device("cuda"))
|
| 28 |
+
else:
|
| 29 |
+
print("diarize_wav_file Using CPU")
|
| 30 |
|
| 31 |
def diarize_wav_file(file_name):
|
| 32 |
print("DIARIZING " + file_name)
|
src/transcribe_files.py
CHANGED
|
@@ -1,10 +1,18 @@
|
|
| 1 |
import os
|
| 2 |
|
| 3 |
import whisper
|
|
|
|
| 4 |
import time
|
| 5 |
def transcribe_segments(speakers):
|
| 6 |
print(f"Whisper models {whisper.available_models()}")
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
#model = whisper.load_model("medium.en", device="cuda")
|
| 9 |
# model = whisper.load_model("turbo", device="cuda")
|
| 10 |
#model = whisper.load_model("large-v3-turbo", device="cuda")
|
|
|
|
| 1 |
import os
|
| 2 |
|
| 3 |
import whisper
|
| 4 |
+
import torch
|
| 5 |
import time
|
| 6 |
def transcribe_segments(speakers):
|
| 7 |
print(f"Whisper models {whisper.available_models()}")
|
| 8 |
+
if torch.cuda.is_available():
|
| 9 |
+
print("transcribe_segments Using CUDA")
|
| 10 |
+
device = "cuda"
|
| 11 |
+
else:
|
| 12 |
+
device = "cpu"
|
| 13 |
+
print("transcribe_segments Using CPU")
|
| 14 |
+
|
| 15 |
+
model = whisper.load_model("tiny.en", device=device)
|
| 16 |
#model = whisper.load_model("medium.en", device="cuda")
|
| 17 |
# model = whisper.load_model("turbo", device="cuda")
|
| 18 |
#model = whisper.load_model("large-v3-turbo", device="cuda")
|
src/transcript_analysis.py
CHANGED
|
@@ -121,8 +121,8 @@ def transcript_analysis(transcript):
|
|
| 121 |
input += speaker + "\n"
|
| 122 |
|
| 123 |
start = time.time()
|
| 124 |
-
response = use_huggingface2(input)
|
| 125 |
-
|
| 126 |
#response = use_bigbird_pegasus_large_arxiv(input)
|
| 127 |
stop = time.time()
|
| 128 |
elapsed=stop-start
|
|
|
|
| 121 |
input += speaker + "\n"
|
| 122 |
|
| 123 |
start = time.time()
|
| 124 |
+
# response = use_huggingface2(input)
|
| 125 |
+
response = use_openai(input)
|
| 126 |
#response = use_bigbird_pegasus_large_arxiv(input)
|
| 127 |
stop = time.time()
|
| 128 |
elapsed=stop-start
|