Timestamp sentence en. Args: punc_id_list: TODO. timestamp_postprocessed: TODO. text_postprocessed: TODO. return_raw_text: TODO.
(
punc_id_list, timestamp_postprocessed, text_postprocessed, return_raw_text=False
)
| 221 | |
| 222 | |
| 223 | def timestamp_sentence_en( |
| 224 | punc_id_list, timestamp_postprocessed, text_postprocessed, return_raw_text=False |
| 225 | ): |
| 226 | """Timestamp sentence en. |
| 227 | |
| 228 | Args: |
| 229 | punc_id_list: TODO. |
| 230 | timestamp_postprocessed: TODO. |
| 231 | text_postprocessed: TODO. |
| 232 | return_raw_text: TODO. |
| 233 | """ |
| 234 | punc_list = [",", ".", "?", ","] |
| 235 | res = [] |
| 236 | if text_postprocessed is None: |
| 237 | return res |
| 238 | if timestamp_postprocessed is None: |
| 239 | return res |
| 240 | if len(timestamp_postprocessed) == 0: |
| 241 | return res |
| 242 | if len(text_postprocessed) == 0: |
| 243 | return res |
| 244 | |
| 245 | if punc_id_list is None or len(punc_id_list) == 0: |
| 246 | res.append( |
| 247 | { |
| 248 | "text": text_postprocessed.split(), |
| 249 | "start": timestamp_postprocessed[0][0], |
| 250 | "end": timestamp_postprocessed[-1][1], |
| 251 | "timestamp": timestamp_postprocessed, |
| 252 | } |
| 253 | ) |
| 254 | return res |
| 255 | if len(punc_id_list) != len(timestamp_postprocessed): |
| 256 | logging.warning("length mismatch between punc and timestamp") |
| 257 | sentence_text = "" |
| 258 | sentence_text_seg = "" |
| 259 | ts_list = [] |
| 260 | sentence_start = timestamp_postprocessed[0][0] |
| 261 | sentence_end = timestamp_postprocessed[0][1] |
| 262 | texts = text_postprocessed.split() |
| 263 | punc_stamp_text_list = list( |
| 264 | zip_longest(punc_id_list, timestamp_postprocessed, texts, fillvalue=None) |
| 265 | ) |
| 266 | is_sentence_start = True |
| 267 | for punc_stamp_text in punc_stamp_text_list: |
| 268 | punc_id, timestamp, text = punc_stamp_text |
| 269 | # sentence_text += text if text is not None else '' |
| 270 | if text is not None: |
| 271 | if "a" <= text[0] <= "z" or "A" <= text[0] <= "Z": |
| 272 | sentence_text += " " + text |
| 273 | elif len(sentence_text) and ( |
| 274 | "a" <= sentence_text[-1] <= "z" or "A" <= sentence_text[-1] <= "Z" |
| 275 | ): |
| 276 | sentence_text += " " + text |
| 277 | else: |
| 278 | sentence_text += text |
| 279 | sentence_text_seg += text + " " |
| 280 | ts_list.append(timestamp) |
no outgoing calls
no test coverage detected
searching dependent graphs…