Skip to content

Commit

Permalink
Fix speech_recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
Unal Ege Gaznepoglu committed Dec 19, 2023
1 parent f0eec76 commit 28e6c58
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions anonymization/modules/text/speech_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def recognize_speech(self, dataset_path, dataset_name=None, utterance_list=None)
start = time.time()

if self.n_processes == 1:
new_texts = [recognition_job([utterances, self.asr_model,
new_texts = [recognition_job([utterances, self.asr_models[0],
dataset_results_dir, 0, self.devices[0], self.model_hparams, None,
save_intermediate])]
else:
sleeps = [10 * i for i in range(self.n_processes)]
indices = np.array_split(np.arange(len(utterances)), self.n_processes)
utterance_jobs = [[utterances[ind] for ind in chunk] for chunk in indices]
# multiprocessing
job_params = zip(utterance_jobs, repeat(self.asr_model), repeat(dataset_results_dir), sleeps,
job_params = zip(utterance_jobs, repeat(self.asr_models), repeat(dataset_results_dir), sleeps,
self.devices, repeat(self.model_hparams), list(range(self.n_processes)),
repeat(save_intermediate))
new_texts = process_map(recognition_job, job_params, max_workers=self.n_processes)
Expand Down Expand Up @@ -127,9 +127,6 @@ def recognition_job(data):
add_suffix = f'_{job_id}' if job_id is not None else None
job_id = job_id or 0

if asr_model is None:
asr_model = create_model_instance(hparams=model_hparams, device=device)

texts = Text(is_phones=(asr_model.output == 'phones'))
i = 0
for utt, spk, wav_path in tqdm(utterances, desc=f'Job {job_id}', leave=True):
Expand Down

0 comments on commit 28e6c58

Please sign in to comment.