MCPcopy Create free account
hub / github.com/modelscope/FunASR / rec_file

Method rec_file

runtime/funasr_api/funasr_core.py:178–195  ·  view source on GitHub ↗
(self,file_path)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

rec_bufMethod · 0.95
audio2wavMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected