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 )
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:
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 )
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 )
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
Formatting the message manually before passing it to a logging
call does unnecessary work if logging in disabled. Consider using the logging
module's built-in formatting features to avoid that.
import logging, inspect
logging.basicConfig(level=logging.INFO)
logging.debug("Entered function {}".format(inspect.stack[0][3]))
import logging, inspect
logging.basicConfig(level=logging.INFO)
logging.debug("Entered function %s", inspect.stack[0][3])