| 176 | return |
| 177 | # rec file |
| 178 | def rec_file(self,file_path): |
| 179 | try: |
| 180 | #self.new_connection() |
| 181 | import os |
| 182 | file_ext=os.path.splitext(file_path)[-1].upper() |
| 183 | |
| 184 | with open(file_path, "rb") as f: |
| 185 | |
| 186 | audio_bytes = f.read() |
| 187 | if not file_ext =="PCM" and not file_ext =="WAV": |
| 188 | audio_bytes=FunasrTools.audio2wav(audio_bytes) |
| 189 | if audio_bytes==None: |
| 190 | print("error, ffmpeg can not decode such file!") |
| 191 | exit(0) |
| 192 | return self.rec_buf(audio_bytes) |
| 193 | except Exception as e: |
| 194 | print("rec_file",e) |
| 195 | return |
| 196 | def wait_for_result(self): |
| 197 | try: |
| 198 | timeout=self.timeout |