yujuanqin commited on
Commit
b27f71f
·
1 Parent(s): 6b76e6e

fix ZeroDivisionError

Browse files
Files changed (1) hide show
  1. lib/report.py +3 -3
lib/report.py CHANGED
@@ -143,7 +143,7 @@ class DelayItem:
143
  current_row.tsb_opt = i.content
144
  elif i.tag == LogTag.transcribe_cost:
145
  current_row.tsb_cost = time_to_float(i.content)
146
- current_row.tsb_cost_per_second = current_row.tsb_cost/current_row.audio_length
147
  elif i.tag == LogTag.translate_start:
148
  current_row.tsl_ipt = i.content
149
  elif i.tag in [LogTag.translate_end, LogTag.translate_large_end]:
@@ -155,7 +155,7 @@ class DelayItem:
155
  current_row.web_src = web_item.src_text
156
  current_row.web_dst = web_item.dst_text
157
  current_row.web_delay = (current_row.web_tsp - current_row.audio_end_tsp).total_seconds()
158
- current_row.web_delay_per_second = current_row.web_delay / current_row.audio_length
159
  # 删除 dict已匹配过的内容,避免多次匹配
160
  web_items_dict.pop(current_row.tsb_opt+current_row.tsl_opt)
161
  if len(detail_rows)>=1 and detail_rows[-1].web_tsp:
@@ -163,7 +163,7 @@ class DelayItem:
163
 
164
  elif i.tag in [LogTag.translate_cost, LogTag.translate_large_cost]:
165
  current_row.tsl_cost = time_to_float(i.content)
166
- current_row.tsl_cost_per_second = current_row.tsl_cost/current_row.audio_length
167
  summary = self.get_summary(summary, detail_rows)
168
  return summary, detail_rows # [astuple(i) for i in rows]
169
  def get_summary(self,summary: DelaySummary, detail_rows):
 
143
  current_row.tsb_opt = i.content
144
  elif i.tag == LogTag.transcribe_cost:
145
  current_row.tsb_cost = time_to_float(i.content)
146
+ current_row.tsb_cost_per_second = current_row.tsb_cost/current_row.audio_length if current_row.audio_length else 0
147
  elif i.tag == LogTag.translate_start:
148
  current_row.tsl_ipt = i.content
149
  elif i.tag in [LogTag.translate_end, LogTag.translate_large_end]:
 
155
  current_row.web_src = web_item.src_text
156
  current_row.web_dst = web_item.dst_text
157
  current_row.web_delay = (current_row.web_tsp - current_row.audio_end_tsp).total_seconds()
158
+ current_row.web_delay_per_second = current_row.web_delay / current_row.audio_length if current_row.audio_length else 0
159
  # 删除 dict已匹配过的内容,避免多次匹配
160
  web_items_dict.pop(current_row.tsb_opt+current_row.tsl_opt)
161
  if len(detail_rows)>=1 and detail_rows[-1].web_tsp:
 
163
 
164
  elif i.tag in [LogTag.translate_cost, LogTag.translate_large_cost]:
165
  current_row.tsl_cost = time_to_float(i.content)
166
+ current_row.tsl_cost_per_second = current_row.tsl_cost/current_row.audio_length if current_row.audio_length else 0
167
  summary = self.get_summary(summary, detail_rows)
168
  return summary, detail_rows # [astuple(i) for i in rows]
169
  def get_summary(self,summary: DelaySummary, detail_rows):