Explorar o código

fix modelscope inference result is empty

lzr265946 %!s(int64=3) %!d(string=hai) anos
pai
achega
fede646200
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      funasr/bin/modelscope_infer.py

+ 4 - 1
funasr/bin/modelscope_infer.py

@@ -82,6 +82,9 @@ if __name__ == '__main__':
             wav_id, wav_path = line.strip().split()
             logging.info("decoding, utt_id: ['{}']".format(wav_id))
             rec_result = inference_pipeline(audio_in=wav_path)
-            text = rec_result["text"]
+            if 'text' in rec_result:
+                text = rec_result["text"]
+            else:
+                text = ''
             f_out.write(wav_id + " " + text + "\n")
             logging.info("best hypo: {} \n".format(text))