from funasr import AutoModel
print("2222")
def play_audio(text):
print(text)
if __name__ == '__main__':
audio_process = multiprocessing.Process(target=play_audio, args=("1111",))
audio_process.start() # 启动进程
audio_process_id = audio_process.pid
解决方法:
把只需要执行一遍的逻辑或者python import耗时的包放到main函数里
测试下来from funasr import AutoModel非常耗时,如果放在外面启动子进程都会再次执行会非常影响
def play_audio(text):
print(text)
if __name__ == '__main__':
from funasr import AutoModel
print("2222")
audio_process = multiprocessing.Process(target=play_audio, args=("1111",))
audio_process.start() # 启动进程
audio_process_id = audio_process.pid