建立funasr连接异常:Connection to remote host was lost./TypeError: SQLite3 can only bind numbers, strings, bigints, buffers, and null
环境:
显卡4060 内存32GB docker-desktop、wsl2
问题日志:
` 2025-06-22 14:12:19.572 | INFO | asr_fun:asr:102 - fun asr start, wav_path:/code/data/origin_audio/format_denoise_20250622221215144.wav
2025-06-22 14:12:19.576 | INFO | asr_fun:init_conn:40 - connect to url
2025-06-22 14:12:19.659 | WARNING | asr_fun:init_conn:53 - 建立funasr连接异常:Connection to remote host was lost.
Traceback (most recent call last):
File "/code/asr_fun.py", line 41, in init_conn
self.websocket = create_connection(uri, ssl=ssl_context, sslopt=ssl_opt)
File "/opt/conda/envs/python310/lib/python3.10/site-packages/websocket/_core.py", line 646, in create_connection
websock.connect(url, **options)
File "/opt/conda/envs/python310/lib/python3.10/site-packages/websocket/_core.py", line 261, in connect
self.handshake_response = handshake(self.sock, url, *addrs, **options)
File "/opt/conda/envs/python310/lib/python3.10/site-packages/websocket/_handshake.py", line 65, in handshake
status, resp = _get_resp_headers(sock)
File "/opt/conda/envs/python310/lib/python3.10/site-packages/websocket/_handshake.py", line 141, in _get_resp_headers
status, resp_headers, status_message = read_headers(sock)
File "/opt/conda/envs/python310/lib/python3.10/site-packages/websocket/_http.py", line 351, in read_headers
line = recv_line(sock)
File "/opt/conda/envs/python310/lib/python3.10/site-packages/websocket/_socket.py", line 140, in recv_line
c = recv(sock, 1)
File "/opt/conda/envs/python310/lib/python3.10/site-packages/websocket/_socket.py", line 132, in recv
raise WebSocketConnectionClosedException("Connection to remote host was lost.")
websocket._exceptions.WebSocketConnectionClosedException: Connection to remote host was lost.
2025-06-22 14:12:35.696 | ERROR | tools.server.views_guiji:api_do_preprocess:118 - An error occurred: 'NoneType' object has no attribute 'send'
Stack trace:
Traceback (most recent call last):
File "/code/tools/server/views_guiji.py", line 105, in api_do_preprocess
rt = generate_reference_info(tts_item)
File "/code/tools/server/views_guiji.py", line 76, in generate_reference_info
text = asr_fun.asr(a_file)
File "/code/asr_fun.py", line 120, in asr
result: dict = rcg.close(timeout=3)
File "/code/asr_fun.py", line 86, in close
self.websocket.send(message)
AttributeError: 'NoneType' object has no attribute 'send'
2025-06-22 14:12:35.697 | INFO | tools.server.views_guiji:api_do_preprocess:121 - 训练返回结果:{'code': -1, 'msg': "'NoneType' object has no attribute 'send'"}`
关键问题定位: 建立funasr连接异常:Connection to remote host was lost
已查阅解决方案,但仍未解决:
通过查看issues,总结了几种方法 一是扩容内存至32GB 二是更改wsl配置内存至30GB 三是若视频无音频会出错,测试了几个视频带音频无杂音都还是一样报错
目前定位不知道asr服务是否正常服务,日志如下:
`2025-06-22 22:09:13,933 - modelscope - INFO - Use user-specified model revision: v1.0.2
Notice: ffmpeg is not installed. torchaudio is used to load audio
If you want to use ffmpeg backend to load audio, please install it by:
sudo apt install ffmpeg # ubuntu
# brew install ffmpeg # mac
transformer is not installed, please install it if you want to use related modules
I20250622 22:09:15.801321 76 funasr-wss-server.cpp:400] Set lm-dir : /workspace/models/damo/speech_ngram_lm_zh-cn-ai-wesp-fst
I20250622 22:09:15.801400 76 funasr-wss-server.cpp:418] Download model: damo/punc_ct-transformer_cn-en-common-vocab471067-large-onnx from modelscope:
/usr/lib/python3.8/runpy.py:127: RuntimeWarning: 'funasr.download.runtime_sdk_download_tool' found in sys.modules after import of package 'funasr.download', but prior to execution of 'funasr.download.runtime_sdk_download_tool'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
2025-06-22 22:09:18,878 - modelscope - INFO - PyTorch version 1.12.0+cu113 Found.
2025-06-22 22:09:18,878 - modelscope - INFO - Loading ast index from /root/.cache/modelscope/ast_indexer
2025-06-22 22:09:18,906 - modelscope - INFO - Loading done! Current index file version is 1.15.0, with md5 c4b646b5c8170030c944e33a556bb234 and a total number of 980 components indexed
2025-06-22 22:09:20,247 - modelscope - INFO - Use user-specified model revision: v2.0.5
Notice: ffmpeg is not installed. torchaudio is used to load audio
If you want to use ffmpeg backend to load audio, please install it by:
sudo apt install ffmpeg # ubuntu
# brew install ffmpeg # mac
transformer is not installed, please install it if you want to use related modules
I20250622 22:09:21.843633 76 funasr-wss-server.cpp:437] Set punc-dir : /workspace/models/damo/punc_ct-transformer_cn-en-common-vocab471067-large-onnx
I20250622 22:09:21.843735 76 funasr-wss-server.cpp:466] hotword path: /workspace/FunASR/runtime/websocket/hotwords.txt
I20250622 22:09:21.844802 76 util.cpp:1013] hotwords:
I20250622 22:09:21.845314 76 util.cpp:1042] 阿里巴巴 : 20
I20250622 22:09:21.845383 76 util.cpp:1042] 通义实验室 : 30
I20250622 22:09:21.847994 76 funasr-wss-server.cpp:497] SSL is closed!
I20250622 22:09:21.908180 76 fsmn-vad.cpp:58] Successfully load model from /workspace/models/damo/speech_fsmn_vad_zh-cn-16k-common-onnx/model_quant.onnx
I20250622 22:09:21.962977 76 paraformer-torch.cpp:41] CUDA is available, running on GPU
I20250622 22:09:31.962293 76 paraformer-torch.cpp:52] Successfully load model from /workspace/models/damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch/model_blade.torchscript
2025-06-22 22:09:36.120041: I external/org_tensorflow/tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:982] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2025-06-22 22:09:37.948075: I external/org_tensorflow/tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:424] Loaded cuDNN version 8302
I20250622 22:09:51.837343 76 paraformer-torch.cpp:75] Successfully load lm file /workspace/models/damo/speech_ngram_lm_zh-cn-ai-wesp-fst/TLG.fst
I20250622 22:09:54.194478 76 ct-transformer.cpp:21] Successfully load model from /workspace/models/damo/punc_ct-transformer_cn-en-common-vocab471067-large-onnx/model_quant.onnx
I20250622 22:09:55.668452 76 tokenizer.cpp:40] Successfully load file from /workspace/models/damo/punc_ct-transformer_cn-en-common-vocab471067-large-onnx/jieba.c.dict, /workspace/models/damo/punc_ct-transformer_cn-en-common-vocab471067-large-onnx/jieba_usr_dict
I20250622 22:09:55.683024 76 tokenizer.cpp:48] Successfully load model from /workspace/models/damo/punc_ct-transformer_cn-en-common-vocab471067-large-onnx/jieba.hmm
I20250622 22:09:55.686939 76 itn-processor.cpp:33] Successfully load model from /workspace/models/thuduj12/fst_itn_zh/zh_itn_tagger.fst
I20250622 22:09:55.688210 76 itn-processor.cpp:35] Successfully load model from /workspace/models/thuduj12/fst_itn_zh/zh_itn_verbalizer.fst
I20250622 22:09:55.688241 76 websocket-server.cpp:423] model successfully inited
I20250622 22:09:55.688246 76 websocket-server.cpp:425] initAsr run check_and_clean_connection
I20250622 22:09:55.688429 76 websocket-server.cpp:428] initAsr run check_and_clean_connection finished
I20250622 22:09:55.688448 76 funasr-wss-server.cpp:513] decoder-thread-num: 20
I20250622 22:09:55.688452 76 funasr-wss-server.cpp:514] io-thread-num: 2
I20250622 22:09:55.688454 76 funasr-wss-server.cpp:515] model-thread-num: 1
I20250622 22:09:55.688455 76 funasr-wss-server.cpp:516] asr model init finished. listen on port:10095`
\AppData\Roaming\heygem.ai\logs\main.log日志如下
2025-06-22 22:12:16 [info] audio split done 2025-06-22 22:12:16 [debug] ~ preprocessAndTran ~ param: {"format":"wav","reference_audio":"origin_audio/20250622221215144.wav","lang":"zh"} 2025-06-22 22:12:35 [debug] ~ train ~ res: { code: -1, msg: "'NoneType' object has no attribute 'send'" } 2025-06-22 22:12:35 [debug] [SQL Run]: INSERT INTO f2f_model (name, video_path, audio_path, voice_id, created_at) VALUES (?, ?, ?, ?, ?) [ 'tim', '20250622221215144.mp4', 'origin_audio\\20250622221215144.wav', false, 1750601555286 ]
如若还需什么日志,还麻烦各位大佬可以留言一下,目前仍未解决问题。
使用的是docker-compose.yml,未修改文件任何配置
你上面voice_id 的值传的是false ,应该是ffmpeg 提取音频的时候没有没有提取到,所以执行insert 的时候没有返回正常的id
这位朋友,很高兴认识你,你的来信我已经收到,请等待回复,小铨QQ1962742134,前线卡盟:qianxian.050ka.com,欢迎加盟!
感谢回复,通过排查,我发现原因是本机开了代理,导致内部也映射代理,然后服务互相之间无法访问。将本机代理取消掉重启docker即可解决问题
汉堡 @.***
两种问题,一种是视频没声音一种是内存没达到32g
FunASR启动的过程很慢,cpu占用超过100%%,但是最后docker服务显示运行中,j进去容器查看端口,其实10095没有启动成功,那确实是服务器启动失败了,后台日志显示模型加载失败,确定就是内存不足问题,这时候你需要修改WSL的.wslconfig的全局配置,内存设置大于15G