Spaces:
Runtime error
Runtime error
Spawn a new process for each GPU
Browse files- src/vadParallel.py +6 -1
src/vadParallel.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from src.vad import AbstractTranscription, TranscriptionConfig
|
2 |
from src.whisperContainer import WhisperCallback
|
3 |
|
@@ -22,6 +23,7 @@ class ParallelTranscription(AbstractTranscription):
|
|
22 |
merged = transcription.get_merged_timestamps(audio, config)
|
23 |
|
24 |
# Split into a list for each device
|
|
|
25 |
merged_split = self._chunks(merged, len(merged) // len(devices))
|
26 |
|
27 |
# Parameters that will be passed to the transcribe function
|
@@ -43,7 +45,10 @@ class ParallelTranscription(AbstractTranscription):
|
|
43 |
'language': None
|
44 |
}
|
45 |
|
46 |
-
|
|
|
|
|
|
|
47 |
# Run the transcription in parallel
|
48 |
results = p.starmap(self.transcribe, parameters)
|
49 |
|
|
|
1 |
+
import multiprocessing
|
2 |
from src.vad import AbstractTranscription, TranscriptionConfig
|
3 |
from src.whisperContainer import WhisperCallback
|
4 |
|
|
|
23 |
merged = transcription.get_merged_timestamps(audio, config)
|
24 |
|
25 |
# Split into a list for each device
|
26 |
+
# TODO: Split by time instead of by number of chunks
|
27 |
merged_split = self._chunks(merged, len(merged) // len(devices))
|
28 |
|
29 |
# Parameters that will be passed to the transcribe function
|
|
|
45 |
'language': None
|
46 |
}
|
47 |
|
48 |
+
# Spawn a separate process for each device
|
49 |
+
context = multiprocessing.get_context('spawn')
|
50 |
+
|
51 |
+
with context.Pool(len(devices)) as p:
|
52 |
# Run the transcription in parallel
|
53 |
results = p.starmap(self.transcribe, parameters)
|
54 |
|