HHousen / lecture2notes

Lazy formatting of message string passed to logging module PYL-W1202
Performance
Minor
9 months ago9 months old
Use lazy % formatting in logging functions
 318
 319        explained_variance = svd.explained_variance_ratio_.sum()
 320        logger.debug(
 321            "Explained variance of the SVD step: {}%".format( 322                int(explained_variance * 100)
 323            )
 324        )
Use lazy % formatting in logging functions
519    model.setBeamWidth(beam_width)
520
521    if scorer:
522        logger.debug("Loading scorer from files {}".format(scorer))523        model.enableExternalScorer(scorer)
524
525        if lm_alpha and lm_beta:
Use lazy % formatting in logging functions
350                )
351            if sample_rate != desired_sample_rate:
352                logger.warn(
353                    "Original sample rate ({}) is different than {}hz. Resampling might produce erratic speech recognition.".format(354                        sample_rate, desired_sample_rate
355                    )
356                )
Use lazy % formatting in logging functions
344            # different warning message depending on the problem (or both messages)
345            if num_channels != 1:
346                logger.warn(
347                    "Resampling to one channel since {} channels were detected".format(348                        num_channels
349                    )
350                )
Use lazy % formatting in logging functions
 99    except sr.UnknownValueError:
100        logger.error("Could not understand audio")
101    except sr.RequestError as e:
102        logger.error("Error; {}".format(e))103
104    return transcript
105