(cust_path: Optional[str], coef: Optional[str])
| 73 | |
| 74 | |
| 75 | def load_chat(cust_path: Optional[str], coef: Optional[str]) -> bool: |
| 76 | global enable_cache, experimental |
| 77 | |
| 78 | if cust_path == None: |
| 79 | ret = chat.load(coef=coef, enable_cache=enable_cache, experimental=experimental) |
| 80 | else: |
| 81 | logger.info("local model path: %s", cust_path) |
| 82 | ret = chat.load( |
| 83 | "custom", |
| 84 | custom_path=cust_path, |
| 85 | coef=coef, |
| 86 | enable_cache=enable_cache, |
| 87 | experimental=experimental, |
| 88 | ) |
| 89 | global custom_path |
| 90 | custom_path = cust_path |
| 91 | if ret: |
| 92 | try: |
| 93 | chat.normalizer.register("en", normalizer_en_nemo_text()) |
| 94 | except ValueError as e: |
| 95 | logger.error(e) |
| 96 | except: |
| 97 | logger.warning("Package nemo_text_processing not found!") |
| 98 | logger.warning( |
| 99 | "Run: conda install -c conda-forge pynini=2.1.5 && pip install nemo_text_processing", |
| 100 | ) |
| 101 | try: |
| 102 | chat.normalizer.register("zh", normalizer_zh_tn()) |
| 103 | except ValueError as e: |
| 104 | logger.error(e) |
| 105 | except: |
| 106 | logger.warning("Package WeTextProcessing not found!") |
| 107 | logger.warning( |
| 108 | "Run: conda install -c conda-forge pynini=2.1.5 && pip install WeTextProcessing", |
| 109 | ) |
| 110 | return ret |
| 111 | |
| 112 | |
| 113 | def reload_chat(coef: Optional[str]) -> str: |
no test coverage detected