Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not load model if it's already loaded #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions align/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ def read_script(script_path):

def init_stt(output_graph_path, lm_path, trie_path):
global model
model = deepspeech.Model(output_graph_path, BEAM_WIDTH)
model.enableDecoderWithLM(lm_path, trie_path, LM_ALPHA, LM_BETA)
logging.debug('Process {}: Loaded models'.format(os.getpid()))
if model is None:
model = deepspeech.Model(output_graph_path, BEAM_WIDTH)
model.enableDecoderWithLM(lm_path, trie_path, LM_ALPHA, LM_BETA)
logging.debug('Process {}: Loaded models'.format(os.getpid()))


def stt(sample):
Expand Down Expand Up @@ -498,10 +499,10 @@ def pre_filter():

samples = list(progress(pre_filter(), desc='VAD splitting'))

pool = multiprocessing.Pool(initializer=init_stt,
with multiprocessing.Pool(initializer=init_stt,
initargs=(output_graph_path, lm_path, trie_path),
processes=args.stt_workers)
transcripts = list(progress(pool.imap(stt, samples), desc='Transcribing', total=len(samples)))
processes=args.stt_workers) as pool:
transcripts = list(progress(pool.imap(stt, samples), desc='Transcribing', total=len(samples)))

fragments = []
for time_start, time_end, segment_transcript in transcripts:
Expand Down