alessandro trinca tornidor commited on
Commit
51b11b3
·
1 Parent(s): 767e8bd

feat: improve logs and comments

Browse files
aip_trainer/WordMatching.py CHANGED
@@ -84,7 +84,7 @@ def get_best_path_from_distance_matrix(word_distance_matrix):
84
  return []
85
 
86
 
87
- def get_resulting_string(mapped_indices: np.array, words_estimated: list, words_real: list) -> list:
88
  mapped_words = []
89
  mapped_words_indices = []
90
  WORD_NOT_FOUND_TOKEN = '-'
 
84
  return []
85
 
86
 
87
+ def get_resulting_string(mapped_indices: np.array, words_estimated: list, words_real: list) -> tuple[list, list]:
88
  mapped_words = []
89
  mapped_words_indices = []
90
  WORD_NOT_FOUND_TOKEN = '-'
aip_trainer/lambdas/lambdaSpeechToScore.py CHANGED
@@ -50,7 +50,7 @@ def lambda_handler(event, context):
50
 
51
  start = time.time()
52
  app_logger.info(f'Loading .ogg file file {random_file_name} ...')
53
- signal, fs = audioread_load(random_file_name)
54
 
55
  duration = time.time() - start
56
  app_logger.info(f'Read .ogg file {random_file_name} in {duration}s.')
@@ -86,8 +86,9 @@ def lambda_handler(event, context):
86
 
87
  is_letter_correct_all_words = ''
88
  for idx, word_real in enumerate(words_real):
89
- mapped_letters, mapped_letters_indices = wm.get_best_mapped_words(
90
- mapped_words[idx], word_real)
 
91
 
92
  is_letter_correct = wm.getWhichLettersWereTranscribedCorrectly(
93
  word_real, mapped_letters) # , mapped_letters_indices)
 
50
 
51
  start = time.time()
52
  app_logger.info(f'Loading .ogg file file {random_file_name} ...')
53
+ signal, _ = audioread_load(random_file_name)
54
 
55
  duration = time.time() - start
56
  app_logger.info(f'Read .ogg file {random_file_name} in {duration}s.')
 
86
 
87
  is_letter_correct_all_words = ''
88
  for idx, word_real in enumerate(words_real):
89
+ mapped_letters, _ = wm.get_best_mapped_words(
90
+ mapped_words[idx], word_real
91
+ )
92
 
93
  is_letter_correct = wm.getWhichLettersWereTranscribedCorrectly(
94
  word_real, mapped_letters) # , mapped_letters_indices)
aip_trainer/models/RuleBasedModels.py CHANGED
@@ -13,10 +13,9 @@ class EpitranPhonemConverter(ModelInterfaces.ITextToPhonemModel):
13
  self.epitran_model = epitran_model
14
 
15
  def convertToPhonem(self, sentence: str) -> str:
16
-
17
- app_logger.info(f'starting EpitranPhonemConverter.convertToPhonem...')
18
  phonem_representation = self.epitran_model.transliterate(sentence)
19
- app_logger.info(f'EpitranPhonemConverter: got phonem_representation!')
20
  return phonem_representation
21
 
22
 
@@ -26,6 +25,8 @@ class EngPhonemConverter(ModelInterfaces.ITextToPhonemModel):
26
  super().__init__()
27
 
28
  def convertToPhonem(self, sentence: str) -> str:
 
29
  phonem_representation = eng_to_ipa.convert(sentence)
30
  phonem_representation = phonem_representation.replace('*','')
 
31
  return phonem_representation
 
13
  self.epitran_model = epitran_model
14
 
15
  def convertToPhonem(self, sentence: str) -> str:
16
+ app_logger.debug(f'starting EpitranPhonemConverter.convertToPhonem for sentence/token "{sentence}"...')
 
17
  phonem_representation = self.epitran_model.transliterate(sentence)
18
+ app_logger.debug(f'EpitranPhonemConverter: got phonem_representation for sentence/token "{sentence}"!')
19
  return phonem_representation
20
 
21
 
 
25
  super().__init__()
26
 
27
  def convertToPhonem(self, sentence: str) -> str:
28
+ app_logger.debug(f'starting EngPhonemConverter.convertToPhonem for sentence/token "{sentence}"...')
29
  phonem_representation = eng_to_ipa.convert(sentence)
30
  phonem_representation = phonem_representation.replace('*','')
31
+ app_logger.debug(f'EngPhonemConverter: got phonem_representation for sentence/token "{sentence}"!')
32
  return phonem_representation
webApp.py CHANGED
@@ -31,7 +31,6 @@ def getNext():
31
  @app.route(rootPath+'/GetAccuracyFromRecordedAudio', methods=['POST'])
32
  def GetAccuracyFromRecordedAudio():
33
  try:
34
- # todo: inserire
35
  event = {'body': json.dumps(request.get_json(force=True))}
36
  lambda_correct_output = lambdaSpeechToScore.lambda_handler(event, [])
37
  return lambda_correct_output
 
31
  @app.route(rootPath+'/GetAccuracyFromRecordedAudio', methods=['POST'])
32
  def GetAccuracyFromRecordedAudio():
33
  try:
 
34
  event = {'body': json.dumps(request.get_json(force=True))}
35
  lambda_correct_output = lambdaSpeechToScore.lambda_handler(event, [])
36
  return lambda_correct_output